Is it possible to have a Moxy xml-bindings oxm file for an object such as shown below. The object has a Map that is Keyed with name of the parameter, and Value would be a configured value. Each parameter has its own xml-path. The question is where can I specify the xml-path for the virtual props?. I could use the key as xpath itself. But, still not sure how the binding will turn into...
public class ServiceData{
String Id;
String desc;
@XmlTransient
private Map<String, Object> parameters= new HashMap<>();
public Object getCustomProps(String name){
return parameters.get(name);
}
public void putCustomProps(String name, Object value){
parameters.put(name, value);
}
}
The binding file may look like below, but, I am stuck on how I would assign xml-path to each entry in the map.
<?xml version="1.0" encoding="US-ASCII"?>
<xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm" package-name="net.blah.blah.domain">
<java-types>
<java-type name="ServiceData">
<xml-virtual-access-methods get-method="getCustomProps" set-method="putCustomProps" />
<xml-root-element name="serviceData"/>
<java-attributes>
<xml-element java-attribute="id"
type="java.lang.String"
xml-path="parameters/group[@name='group1']/parameter[@name='param1']/text()"/>
</java-attributes>
</java-type>
</java-types>
I was able to accomplish this with the following binding. I chose the json binding as that is what I actually need, but, it is similar to XML binding as well.
Pojo is
Application code looks like