[xsd-users] Error parsing nested elements
Constantin Iacobescu
sir.costy at gmail.com
Tue Mar 3 11:38:47 EST 2009
Hi,
I'm parsing a xml file which is made using the LandXML-1.2 schema. Till I
did not had nested elements the things was ok. Then I thought to get a bit
deeper.
This is the binding command used:
xsd cxx-tree --generate-serialization --generate-polymorphic
--generate-doxygen --generate-wildcard --generate-ostream --root-element-all
--type-naming java --function-naming java --namespace-map
http://www.landxml.org/schema/LandXML-1.2=LandXML_12 LandXML-1.2.xsd
After including in the xml file nested elements I get parser runing error
like this:
"InXML.xml:19:13 error: element 'CgPoint' is not allowed for content model
'<<CGPoint,CgPoints>,Feature>'
The XSD CgPoints is like:
<xs:element name="CgPoints">
<xs:annotation>
<xs:documentation>A collection of COGO points. (Cg = COGO = Cordinate
Geometry)</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element ref="CgPoint" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="CgPoints" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="Feature" minOccurs="0" maxOccurs="unbounded"/>
<!-- Allow nested CgPoints collections -->
</xs:sequence>
<xs:attribute name="desc" type="xs:string"/>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="state" type="stateType"/>
<xs:attribute name="code" type="xs:string"/>
<xs:attribute name="zoneNumber" type="zoneNumberType"/>
<xs:attribute name="DTMAttribute" type="DTMAttributeType"/>
</xs:complexType>
<xs:unique name="uPntName">
<xs:selector xpath="CgPoint"/>
<xs:field xpath="@name"/>
</xs:unique>
</xs:element>
And the xml file looks like this:
<CgPoints name="Level1">
<CgPoint name="10" desc="17">4837.18515853 4938.54608259
9.56751464</CgPoint>
<CgPoint name="11" desc="17">4814.57301769 4926.33931189
10.09267518</CgPoint>
<CgPoint name="12" desc="17">4768.07489136 4942.62719383
9.71152459</CgPoint>
<CgPoints name="Level2">
<CgPoint name="13" desc="17">4720.62990560 4943.01498325
10.39206007</CgPoint>
<CgPoint name="14" desc="17">4672.47163351 4943.66059514
11.02326614</CgPoint>
<CgPoint name="15" desc="17">4640.62733892 4935.52350112
11.56814872</CgPoint>
</CgPoints>
<CgPoint name="16" desc="17">4608.96231647 4915.99543068
11.92946751</CgPoint>
<CgPoint name="17" desc="17">4577.45525920 4880.77770666
12.94695546</CgPoint>
</CgPoints> <!-- Here should be the line 19 in the file -->
All the main function is doing is:
XMLPlatformUtils::Initialize ();
std::auto_ptr<LandXML> objLandXML ( parseLandXML(fileName,
xml_schema::Flags::dont_initialize));
XMLPlatformUtils::Terminate ();
I don`t know what I'm doin wrong and what that error mean. Please help me if
anyone know what it is about.
Thanks,
Constantin Iacobescu
More information about the xsd-users
mailing list