java - JAXB unmarshalling with @XmlMixed Annotation -


i have problem while unmarshalling xml document. found hints here ("jaxb- @xmlmixed usage reading @xmlvalue , @xmlelement") wasn't able adopt on code.

first.. here example of xml:

    <test>       <content type="text">this content text</content>       <content type="attributes">         <attributegroup name="group1">           <attribute name="attr1">value1</attribute>         </attributegroup>         <attributegroup name="group2">           <attribute name="attr2">value2</attribute>           <attribute name="attr3">value3</attribute>         </attributegroup>       </content>     </test> 

within content block there either text or several attribute groups attributes (never both!). sadly given xml structure , can't change it.

i tried following class structures there must error within xmlmixed annotation. don't know if must use @xmlmixed here or if there better solution!?

    public static class content {       @xmlmixed       private list<string> text;       @xmlelementref(name = "attributegroup", type = attributegroup.class)       private list<attributegroup> attributegroups;       // getter+setter...     }      public static class attributegroup {       @xmlattribute(name="name")       private string name;       @xmlelement(name="attribute", type=attribute.class)       private list<attribute> attributes;       // getter+setter...     }      public static class attribute {       @xmlattribute(name="name")       private string name;       @xmlvalue       private string value;       // getter+setter...     } 


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -