I have been unable to find an answer to this. The <all>
tag is not the answer, as it restricts child elements to maxOccurs=“1”
.
Say you had XSD that included:
<xsd:sequence>
<xsd:element name=“name” type=“xsd:string” minOccurs=“1”/>
<xsd:element name=“children” type=“xsd:string” minOccurs=“0” maxOccurs=“unbounded”/>
</xsd:sequence>
Is there any way to get JAXB to use this XSD to read XML where the ordering of elements is not the same as defined in the XSD?
I am not aware of a full solution with JAXB.
However, the JAXB binding for
<xs:complexType> <xs:choice maxOccurs="unbounded"> <xs:element name="children" type="xs:string"/> <xs:element name="name" type="xs:string"/> </xs:choice> </xs:complexType>
will unmarshall the instances that you want and keeps them stable when marshalling them again.
Downsides are:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.