for the xml:
<foo xmlns="http://ns.com"
xmlns:ext="http://ext.com"
attr="xxx"
ext:bar="yyy">
</foo>
How can I create a Foo class? Specifically, I’d like to be able to separate the ‘ext’ attribute somehow so it is not directly in Foo, but in another class, and in a typesafe way (so not XmlAnyAttribute).
What I optimally wish for is:
class Foo {
Ext ext;
}
class Ext {
String bar;
}
You can map a POJO field/property with
@XmlAttributeif the referenced object has only one mapped field/property with@XmlValue.Foo
Ext
For More Information
UPDATE
Note: I’m the EclipseLink JAXB (MOXy) lead and a member of the JAXB 2 (JSR-222) expert group.
You can leverage the
@XmlPathextension in MOXy for this use case:Foo
Using
@XmlPath(".")indicates that you want the target object represented at the same level in the XML document as the source object.Ext
For More Information