Hi!

When unmarshalling this instance

<foo>
  <bar>bla</bar>
  <bar>blabla</bar>
</foo>

with castor 1.3 generated classes of this schema

<?xml version='1.0'?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";>
  <xs:group name="foobar">
    <xs:choice>
      <xs:element name="bar" type="xs:string"/>
    </xs:choice>
  </xs:group>
  <xs:element name="foo">
      <xs:complexType>
        <xs:sequence>
          <xs:group ref="foobar" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
      </xs:complexType>
  </xs:element>
</xs:schema>

 I do get this exception:

org.exolab.castor.xml.MarshalException: Element with name bar passed to type
foo in incorrect order; It is not allowed to be the last element of this
sequence!{File: [not available]; line: 3; column: 8}
    at
org.exolab.castor.xml.Unmarshaller.convertSAXExceptionToMarshalException(Unmarshaller.java:794)
    at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:760)
    at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:626)
    at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:840)
    at test.Test2.main(Test2.java:17)
Caused by: ValidationException: Element with name bar passed to type foo in
incorrect order; It is not allowed to be the last element of this sequence!
    at
org.exolab.castor.xml.util.XMLClassDescriptorImpl.checkDescriptorForCorrectOrderWithinSequence(XMLClassDescriptorImpl.java:340)
    at
org.exolab.castor.xml.MarshalFramework$InternalXMLClassDescriptor.checkDescriptorForCorrectOrderWithinSequence(MarshalFramework.java:794)
    at
org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1958)
    at
org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1435)
    at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown
Source)
    at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown
Source)
    at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown
Source)
    at
com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown
Source)
    at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
    at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown
Source)
    at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown
Source)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown
Source)
    at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown
Source)
    at
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown
Source)
    at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:748)
    ... 3 more

Is there any workaround for this?

Thanks.

Stephan

Reply via email to