A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
XML and Related Technologies
JAXB unmarshal problem with XSD choice element
Joined: Aug 04, 2010
Aug 04, 2010 08:35:01
I'm experiencing a problem unmarshalling a <choice> element in an XML document using JAXB RI 2.2.1.
The element is defined as follows (the full XSD is too large to post):
<xsd:element name="PatternExpression" type="PatternExpression_Type"/> <xsd:complexType name="PatternExpression_Type"> <xsd:choice> <xsd:element ref="Pattern"/> <xsd:sequence> <xsd:element ref="PatternOperator"/> <xsd:choice maxOccurs="unbounded"> <xsd:element ref="Pattern"/> <xsd:element ref="PatternExpression" minOccurs="0" maxOccurs="unbounded"/> </xsd:choice> </xsd:sequence> </xsd:choice> </xsd:complexType>
Here is the XML I'm trying to unmarshal:
<PatternExpression> <PatternOperator tc="2">and</PatternOperator> <Pattern> <PropertyName>FirstName</PropertyName> <PropertyValue>John</PropertyValue> </Pattern> <Pattern> <PropertyName>LastName</PropertyName> <PropertyValue>Doe</PropertyValue> </Pattern> </PatternExpression>
When I run the document through the unmarshaller, the resulting PatternExpression object contains the PatternOperator and a single
, which happens to be the last one in the sequence.
Does anyone have any suggestions as to why the Pattern objects are not being added to the list?
I would think that the presence of the PatternOperator would allow JAXB to determine what <choice> the element fall into.
FYI, the XML schema is controlled by a 3rd party, so it cannot be modified.
It is sorta covered in the
JavaRanch Style Guide
subject: JAXB unmarshal problem with XSD choice element
need help in XSD.
Multiple url-pattern in filter-mapping OC4j 10.1.3.3 Servlet 2.5
XSD: The element may not overlap error.
Castor fail to marshal/un-marshal valid instance of sequence-of-choice schema.
Setter method for element with maxOccurs="unbounded"
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015