Page 1 of 1

Variable order of elements in xsd

Posted: Thu Nov 11, 2004 7:24 pm
by ody13
Hallo,

this is my code:

<xs:element name="layer">
<xs:complexType>
<xs:choice>
<xs:element name="paragraph" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="position" type="xs:string"/>
<xs:attribute name="alignment" type="xs:string"/>
<xs:attribute name="character_size" type="xs:decimal"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="image" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="position" type="xs:string"/>
<xs:attribute name="scale" type="xs:decimal"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="model" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="position" type="xs:string"/>
<xs:attribute name="rotate" type="xs:string"/>
<xs:attribute name="scale" type="xs:decimal"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>

The problem is that I don't know and I don't wanna specify when the elements "image", "paragraph and "model" accure. I'm looking for a way to have a variable order. The Problem is, that the number of times the element accure is variable, too. It could be like this for example:

image
paragraph
image
image

Without "model" at all.

Thanx for the solution in advance.

-ODY

Posted: Thu Nov 11, 2004 9:37 pm
by george
Hi,

You have specified a model like
( (paragraph)* | (image)* | (model)* )
that is either zero or more pharagraph or zero or more image or zero or more mode.

From your message it seems that you want
(paragraph | image | model)*

That is XML Schema notation will look like

Code: Select all


<xs:element name="layer">
<xs:complexType>
<xs:choice maxOccurs="unbounded" minOccurs="0">
<xs:element name="paragraph">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="position" type="xs:string"/>
<xs:attribute name="alignment" type="xs:string"/>
<xs:attribute name="character_size" type="xs:decimal"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="image">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="position" type="xs:string"/>
<xs:attribute name="scale" type="xs:decimal"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="model">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="position" type="xs:string"/>
<xs:attribute name="rotate" type="xs:string"/>
<xs:attribute name="scale" type="xs:decimal"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
Best Regards,
George

Posted: Fri Nov 12, 2004 1:11 pm
by ody13
thanx, works great...