pixartist
pixartist

Reputation: 1155

XSD Simple collection of elements?

How would I define the following structure in XSD ?

<root>
 <myElement name="a" />
 <myElement name="b" />
 <myElement name="c" />
 <myElement name="d" />
</root>

I can't seem to find the correct XSD definition. It's not a group, nor a sequence nor anything else.

Edit: it seems that this would be done with sequences. Not very intuitive...

Upvotes: 0

Views: 188

Answers (1)

Xstian
Xstian

Reputation: 8282

I used this tool to generate this XSD...

<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:element name="root">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="myElement" maxOccurs="unbounded" minOccurs="0">
          <xs:complexType>
                <xs:attribute type="xs:string" name="name" use="optional"/>           
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

</xs:schema>

Upvotes: 1

Related Questions