[xsd-users] Error parsing nested elements

Boris Kolpackov boris at codesynthesis.com
Wed Mar 4 00:58:01 EST 2009


Hi Constantin,

Constantin Iacobescu <sir.costy at gmail.com> writes:

> <xs:element name="CgPoints">
>   <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:element>

In plain English the content model of the CgPoints element is any
number of CgPoint elements, followed by any number of CgPoints
elements, followed by any number of Feature elements.


> <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>

Now if we look at your XML fragment, we can see that it does not conform
to the above content model: you have two CgPoint elements following a
CgPoints element. If you move the last two CgPoint elements before
CgPoints, then everything should validate Ok.

Boris




More information about the xsd-users mailing list