[xsd-users] Issue with maintaining order
    Babinskas, Albert 
    albert.babinskas at imagingsciences.com
       
    Wed Feb 18 15:12:51 EST 2015
    
    
  
HI,
I have issue with order of my elements.
I have XSD that looks like this:
<xs:complexType name="annotations_t">
    <xs:sequence>
      <xs:element name="pixelWidth" type="xs:int"/>
      <xs:element name="pixelHeight" type="xs:int"/>
      <xs:element name="imageTitle" type="xs:string" minOccurs="0"/>
      <xs:element name="annotationList" minOccurs="0">
        <xs:complexType>
          <xs:sequence>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
              <xs:element ref="tns:ellipse"/>
              <xs:element ref="tns:line"/>
              <xs:element ref="tns:rectangle"/>
...
            </xs:choice>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
Where <tns:line>  looks like this:
  <xs:complexType name="line_t">
    <xs:complexContent>
        <xs:sequence>
          <xs:element name="point1" type="tns:coordinate_t" minOccurs="0"/>
          <xs:element name="point1Type" type="tns:lineCapType_t" minOccurs="0"/>
          <xs:element name="point1Size" type="tns:lineCapSize_t" minOccurs="0"/>
          <xs:element name="point2" type="tns:coordinate_t" minOccurs="0"/>
          <xs:element name="point2Type" type="tns:lineCapType_t" minOccurs="0"/>
          <xs:element name="point2Size" type="tns:lineCapSize_t" minOccurs="0"/>
        </xs:sequence>
    </xs:complexContent>
  </xs:complexType>
Codesynthesis provides me with
AnnotationList.line()
AnnotationList.Polygon()
AnnotationList.Ellipse()
But the order is not preserved.
If I have: Line, 2 Polygons, and another Line. It will be serialized as 2 Lines, and 2 Polygons.
Is there a way to preserve the order in which I serialize?
Secondly If I am reading xml that has mixed lines and polygons, all my lines, and polygons will be in their distinct lists, and not in 1 main list where I could check type. Again same question is there a way to preserve order? Is there a way after XML is parsed into XSD objects, to access DOM structure of that Object? For example if I would be able to access annotationList Document, or have an iterator over the annotationList.
Thank you!
-Albert
Imaging Sciences International
    
    
More information about the xsd-users
mailing list