jaxb - how declare xml-element in xsd-schema -


i have xml elements:

<attribute name="attributename1"             type="typename1">value1</attribute> ... <attribute name="attributename2"             type="typename2">     <row order="1">         <attribute name="attributename3"                     type="typename3">value3</attribute>         ...     </row>     ...  </attribute> 

how these elements can declared in xsd-schema?

you define attribute element has type mixed content. following:

<xsd:element name="attribute">     <xsd:complextype mixed="true">         <xsd:sequence>             <xsd:element name="row" minoccurs="0" maxoccurs="unbounded">                 <xsd:complextype>                     ...                 </xsd:complextype>             </xsd:element>         </xsd:sequence>     </xsd:complextype> </xsd:element> 

this going give jaxb class following end 1 property store both text , row objects.

@xmlaccessortype(xmlaccesstype.field) @xmltype(name = "", proporder = {     "content" }) @xmlrootelement(name = "attribute") public class attribute {      @xmlelementref(name = "row", namespace = "http://www.example.org/schema", type = jaxbelement.class, required = false)     @xmlmixed     protected list<serializable> content;  } 

you happier in long run if following instead.

<attribute name="attributename1" type="typename1">     <value>value1</value> </attribute> 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -