[xsd-users] LandXML serialization issue

Constantin Iacobescu sir.costy at gmail.com
Fri May 20 11:37:04 EDT 2011


Hello Boris,


I try to generate a xml file using a LandXML schema binding.
All fine so far but my problem is that some elements are not serialized in
the order they are added to a collection.
To understand me better I show you the schema and the result that I need

     <xs:element name="Alignment">
         <xs:complexType>
             <xs:choice maxOccurs="unbounded">
                 <xs:choice>
                    <xs:element ref="Start" minOccurs="0" />
                    <xs:element ref="CoordGeom" />
                    <xs:element ref="AlignPIs" minOccurs="0" />
                    <xs:element ref="Cant" minOccurs="0" />
                </xs:choice>
                <xs:element ref="StaEquation" minOccurs="0"
maxOccurs="unbounded" />
                <xs:element ref="Profile" minOccurs="0"
maxOccurs="unbounded" />
                <xs:element ref="CrossSects" minOccurs="0" />
                <xs:element ref="Superelevation" minOccurs="0"
maxOccurs="unbounded" />
                <xs:element ref="Feature" minOccurs="0"
maxOccurs="unbounded" />
            </xs:choice>
            <xs:attribute name="name" type="xs:string" use="required" />
            <xs:attribute name="length" type="xs:double" use="required" />
            <xs:attribute name="staStart" type="xs:double" use="required" />
            <xs:attribute name="desc" type="xs:string" />
            <xs:attribute name="oID" type="xs:string" />
            <xs:attribute name="state" type="stateType" />
        </xs:complexType>
    </xs:element>


And the result should be some like this

        <Alignment name="y" desc="x" staStart="0.000000"
length="54306.27780415">
            <CoordGeom>
                <Line length="1922.75851852" dir="173.393177205369">
                    <Start>4538367.05235564 2588532.52063004</Start>
                    <End>4538588.27618442 2586622.53101275</End>
                </Line>
                <Spiral radiusStart="INF" radiusEnd="3000.00000095"
rot="ccw" spiType="clothoid" length="50.00000000" tanLong="33.33345459"
tanShort="16.66677690" theta="-0.477464829125384">
                    <Start>4538588.27618442 2586622.53101275</Start>
                    <PI>4538592.11137973 2586589.41892324</PI>
                    <End>4538593.89095065 2586572.84742423</End>
                </Spiral>
                <Curve rot="ccw" radius="3000" length="320.70404934"
crvType="arc" chord="320.55136393" tangent="160.50490661"
delta="6.12499616673441">
                    <Start>4538593.89095065 2586572.84742423</Start>
                    <Center>4535611.04085678 2586252.52677627</Center>
                    <End>4538611.04084809 2586252.75515951</End>
                    <PI>4538611.02862921 2586413.26006565</PI>
                </Curve>
                <Spiral radiusStart="3000.00000488" radiusEnd="INF"
rot="ccw" spiType="clothoid" length="50.00000000" tanLong="33.33345459"
tanShort="16.66677690" theta="0.477464828501486">
                    <Start>4538611.04084809 2586252.75515951</Start>
                    <PI>4538611.04211690 2586236.08838266</PI>
                    <End>4538610.76687884 2586202.75606443</End>
                </Spiral>
                <Line length="1841.59544380" dir="180.473103030671">
                    <Start>4538610.76687884 2586202.75606443</Start>
                    <End>4538595.56061945 2584361.22340159</End>
                </Line>
            </CoordGeom>
        </Alignment>


My problem is that using el binding made by XSD the result xml would look
like this

<Alignment name="y" desc="x" staStart="0.000000" length="54306.27780415">
            <CoordGeom>
                <Line length="1922.75851852" dir="173.393177205369">
                    <Start>4538367.05235564 2588532.52063004</Start>
                    <End>4538588.27618442 2586622.53101275</End>
                </Line>
                <Line length="1841.59544380" dir="180.473103030671">
                    <Start>4538610.76687884 2586202.75606443</Start>
                    <End>4538595.56061945 2584361.22340159</End>
                </Line>
                <Curve rot="ccw" radius="3000" length="320.70404934"
crvType="arc" chord="320.55136393" tangent="160.50490661"
delta="6.12499616673441">
                    <Start>4538593.89095065 2586572.84742423</Start>
                    <Center>4535611.04085678 2586252.52677627</Center>
                    <End>4538611.04084809 2586252.75515951</End>
                    <PI>4538611.02862921 2586413.26006565</PI>
                </Curve>
                <Spiral radiusStart="INF" radiusEnd="3000.00000095"
rot="ccw" spiType="clothoid" length="50.00000000" tanLong="33.33345459"
tanShort="16.66677690" theta="-0.477464829125384">
                    <Start>4538588.27618442 2586622.53101275</Start>
                    <PI>4538592.11137973 2586589.41892324</PI>
                    <End>4538593.89095065 2586572.84742423</End>
                </Spiral>
                <Spiral radiusStart="3000.00000488" radiusEnd="INF"
rot="ccw" spiType="clothoid" length="50.00000000" tanLong="33.33345459"
tanShort="16.66677690" theta="0.477464828501486">
                    <Start>4538611.04084809 2586252.75515951</Start>
                    <PI>4538611.04211690 2586236.08838266</PI>
                    <End>4538610.76687884 2586202.75606443</End>
                </Spiral>

            </CoordGeom>
        </Alignment>


The elements are getting ordered by their type and should not.
First the all the elements of type "Line" then all "Curve" ... etc

Thanks and Regards,
Costy


More information about the xsd-users mailing list