[xsd-users] Support for a sequence of choice elements of polymorphic type

Damon Southworth xsd at cloudydaze.co.uk
Thu Oct 10 10:50:55 EDT 2013


Hi

This is my first post to this site. I have been looking at a number of 
posts with similar problems to mine with maintaining sequencing 
information reqarding the sequence of choice elements type data. My 
question though is a little bit different.

Like a previous post I have a part in my xsd schema that looks like this

<xsd:complexType name="MyListType">
     <xsd:sequence>
         <xsd:choice minOccurs="0" maxOccurs="unbounded">
            <xsd:element name="Element_A" type="myns:Element_A_Type"> 
</xsd:elemet>
            <xsd:element name="Element_B" 
type="myns:Element_B_Type"></xsd:element>
             ....
         </xsd:choice>
     </xsd:sequence>
</xsd:complexType>

In the xsd data model, my list is currently represented as a number of 
separate lists;
One list with the Element_A types and one list with the Element_B types 
and so on. This implementation loses the sequence information as 
reported by other posts.

However, both Element_A_Type and Element_B_Types etc. all have a common 
parent class.

   <xsd:complexType name="Element_A_Type">
     <xsd:complexContent>
       <xsd:extension base="myns:Element_Type"/>
     </xsd:complexContent>
   </xsd:complexType>

and...

   <xsd:complexType name="Element_B_Type">
     <xsd:complexContent>
       <xsd:extension base="myns:Element_Type"/>
     </xsd:complexContent>
   </xsd:complexType>

For this type of schema definition the Java XML compiler Jaxb produces a 
single list of the polymorphic parent typeElement_Type to represent this 
sequence.

Can the xsd cxx XML compiler also produce a single list of objects with 
a type of the common parent class for the polymorphic choices with a 
common parent class rather than a sperate list of each choice.?

This would also allow the sequence information to be retained.

Regards,

Damon Southworth



-- 
Damon Southworth



More information about the xsd-users mailing list