[xsd-users] Class generated with sequence cardinality

Andrew Ward andy.ward at hevday.com
Tue May 2 01:49:06 EDT 2006


Hello,
Given the following schema:

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:complexType name="X">
        <xsd:sequence>
            <xsd:element name="S" type="xsd:string" minOccurs="0">
            </xsd:element>
            <xsd:element name="INS" minOccurs="0">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="PS" minOccurs="0">
                            <xsd:complexType>
                                <xsd:sequence>
                                    <xsd:element name="P" 
maxOccurs="unbounded">
                                        <xsd:complexType>
                                            <xsd:sequence>
                                                <xsd:element name="S" 
type="xsd:string" minOccurs="0"/>
                                            </xsd:sequence>
                                        </xsd:complexType>
                                    </xsd:element>
                                </xsd:sequence>
                            </xsd:complexType>
                        </xsd:element>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:element name="hello" type="X"/>

</xsd:schema>

And using the command:
xsd cxx-tree hello.xsd

I get element X::S being generated with sequence cardinality, when I 
would have thought it should have been generated with optional 
cardinality. This is what is generated:

class X {
...
// S
  //
  public:
  struct S
  {
    typedef ::xml_schema::string type;
    typedef ::xsd::cxx::tree::traits< type > traits;
    typedef ::xsd::cxx::tree::sequence< type > container;
    typedef container::iterator iterator;
    typedef container::const_iterator const_iterator;
  };

Am I right in my assumption?

Regards,
Andrew Ward.







More information about the xsd-users mailing list