java - Embedded attributes in JAXB class -
i need map legacy xml can't change. there several elements have hundreds attributes same other elements. attributes have same name postfixed number. xml might this:
<someelement custom1="..." custom2="..." custom78=".."/> <anotherelmenent custom1="..." custom45="..."/>
a solution "works" create base class so:
@xmlaccessortype(field) public class lotsacustomids { @xmlattribute private string custom1; @xmlattribute private string custom2; ... } @xmltype public class someelement extends lotsacustomids { .... }
but it's shame use inheritence here, since java has single inheritence. i'd way jpa/hibernate embedded objects, like:
@xmltype public class someelement { @embeddedattributes private lotsacustomids customids; .... }
anyway this?
note: i'm eclipselink jaxb (moxy) lead.
you use moxy's @xmlpath
extension map use case. when use @xmlpath(".")
pull contents of child object (lotsacustomids
) parent object (someelement
).
@xmltype public class someelement { @xmlpath(".") private lotsacustomids customids; .... }
related information blog
Comments
Post a Comment