Hi All,
 I ran into this issue a while back but just figured out the cause. I'm
using XMLBeans 2.2.0 with JDK 1.5. The issue is that XMLBeans if your xml
document does not have elements in the same order as they are listed in the
XSD, then XMLBeans is unable to parse the document at runtime. 

Below are a dtd,xsd  showing the problem. Has anyone else ran into this
problem and what was your solution. In the sample XML you'll notice all the
LevelOne elements are the same except the 1st which basically has LevelOneC
as the 1st child instead of LevelOneA. XMLBeans will show the following
error when parsing the document as it is now, however if you remove or
change the order in the
First LevelOne element it works fine.
The error that's reported:

Expected element 'LevelOneC' instead of 'LevelOneA' here in element LevelOne
Location of invalid XML: <LevelOneA
SOneA="SONEA_VALUE">LevelOneA_DATA</LevelOneA>

DTD:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Enter you external DTD here -->
<!ELEMENT TestDoc (LevelOne+)>
<!ELEMENT LevelOne (LevelOneA*,LevelOneB*,LevelOneC*)>
<!ATTLIST LevelOne
  SOne CDATA #REQUIRED>
<!ELEMENT LevelOneA (#PCDATA)>
<!ATTLIST LevelOneA
  SOneA CDATA #REQUIRED>
<!ELEMENT LevelOneB (#PCDATA)>
<!ATTLIST LevelOneB
  SOneB CDATA #REQUIRED>

<!ELEMENT LevelOneC (#PCDATA)>
<!ATTLIST LevelOneC
  SOneC CDATA #REQUIRED>

XSD:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
xmlns:wmh="http://www.wmhelp.com/2003/eGenerator";
elementFormDefault="qualified" >
  <xs:element name="TestDoc">
    <xs:annotation>
      <xs:documentation> Enter you external DTD here </xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="LevelOne" maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="LevelOne">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="LevelOneA" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element ref="LevelOneB" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element ref="LevelOneC" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
      <xs:attribute name="SOne" type="xs:string" use="required"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="LevelOneA">
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="xs:string">
          <xs:attribute name="SOneA" type="xs:string" use="required"/>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>
  <xs:element name="LevelOneB">
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="xs:string">
          <xs:attribute name="SOneB" type="xs:string" use="required"/>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>
  <xs:element name="LevelOneC">
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="xs:string">
          <xs:attribute name="SOneC" type="xs:string" use="required"/>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>
</xs:schema>

Sample XML:
<?xml version="1.0" encoding="utf-8"?>

<TestDoc>
  <LevelOne SOne="SONE_VALUE">
      <LevelOneC SOneC="SONEC_VALUE">LevelOneC_DATA</LevelOneC>
    <LevelOneC SOneC="SONEC_VALUE">LevelOneC_DATA</LevelOneC>
    <LevelOneC SOneC="SONEC_VALUE">LevelOneC_DATA</LevelOneC>
    <LevelOneA SOneA="SONEA_VALUE">LevelOneA_DATA</LevelOneA>
    <LevelOneA SOneA="SONEA_VALUE">LevelOneA_DATA</LevelOneA>
    <LevelOneA SOneA="SONEA_VALUE">LevelOneA_DATA</LevelOneA>
    <LevelOneB SOneB="SONEB_VALUE">LevelOneB_DATA</LevelOneB>
    <LevelOneB SOneB="SONEB_VALUE">LevelOneB_DATA</LevelOneB>
    <LevelOneB SOneB="SONEB_VALUE">LevelOneB_DATA</LevelOneB>
  </LevelOne>
  <LevelOne SOne="SONE_VALUE">
    <LevelOneA SOneA="SONEA_VALUE">LevelOneA_DATA</LevelOneA>
    <LevelOneA SOneA="SONEA_VALUE">LevelOneA_DATA</LevelOneA>
    <LevelOneA SOneA="SONEA_VALUE">LevelOneA_DATA</LevelOneA>
    <LevelOneB SOneB="SONEB_VALUE">LevelOneB_DATA</LevelOneB>
    <LevelOneB SOneB="SONEB_VALUE">LevelOneB_DATA</LevelOneB>
    <LevelOneB SOneB="SONEB_VALUE">LevelOneB_DATA</LevelOneB>
    <LevelOneC SOneC="SONEC_VALUE">LevelOneC_DATA</LevelOneC>
    <LevelOneC SOneC="SONEC_VALUE">LevelOneC_DATA</LevelOneC>
    <LevelOneC SOneC="SONEC_VALUE">LevelOneC_DATA</LevelOneC>
  </LevelOne>
  <LevelOne SOne="SONE_VALUE">
    <LevelOneA SOneA="SONEA_VALUE">LevelOneA_DATA</LevelOneA>
    <LevelOneA SOneA="SONEA_VALUE">LevelOneA_DATA</LevelOneA>
    <LevelOneA SOneA="SONEA_VALUE">LevelOneA_DATA</LevelOneA>
    <LevelOneB SOneB="SONEB_VALUE">LevelOneB_DATA</LevelOneB>
    <LevelOneB SOneB="SONEB_VALUE">LevelOneB_DATA</LevelOneB>
    <LevelOneB SOneB="SONEB_VALUE">LevelOneB_DATA</LevelOneB>
    <LevelOneC SOneC="SONEC_VALUE">LevelOneC_DATA</LevelOneC>
    <LevelOneC SOneC="SONEC_VALUE">LevelOneC_DATA</LevelOneC>
    <LevelOneC SOneC="SONEC_VALUE">LevelOneC_DATA</LevelOneC>
  </LevelOne>
</TestDoc>


Thanks for any help/insight anyone can provide. 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to