Another question about indicators

This should cover W3C XML Schema, Relax NG and DTD related problems.
Guest

Another question about indicators

Fri Nov 12, 2004 2:35 pm

Hi,

I wonder how I can set the indicator, that certain elements have to be set before others and only once, while others can occur several times!

This is the example and the elements duration and name have to be set before slide. It doesn't matter if they are set at all or in which order. Slide should occur at least once, but could more than that.
Could be like name | duration | slide | slide...
or duration | slide | slide...

<xs:element name="presentation">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="duration" minOccurs="0" maxOccurs="1"/>
<xs:element ref="name" minOccurs="0" maxOccurs="1" />
<xs:element ref="slide" minOccurs="1" maxOccurs="unbounded"/>
</xs:choice>
</xs:complexType>
</xs:element>

Is it possible to nest indicators like:

<xs:choice>
<xs:all>
<xs:element></xs:element>
<xs:element></xs:element>
<xs:element></xs:element>
</xs:all>
<xs:element></xs:element>
</xs:choice>

Thanx in advance Rainer...
george
Site Admin
Posts: 2100

Fri Nov 12, 2004 7:23 pm

Hi,

If you can enforce name before duration then you can use something like

Code: Select all

<xs:sequence>
 <xs:element ref="name" minOccurs="0"/>
 <xs:element ref="duration" minOccurs="0"/>
 <xs:element ref="slide" maxOccurs="unbounded"/>
</xs:sequence>

If you want to have also duration, name, slide then you can use something like below (it is a little more complicated because you need to avoid ambiguity):

Code: Select all

<xs:choice>
    <xs:sequence>
        <xs:element ref="name"/>
        <xs:element ref="duration" minOccurs="0"/>
        <xs:element ref="slide" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:sequence>
        <xs:element ref="duration"/>
        <xs:element ref="name" minOccurs="0"/>
        <xs:element ref="slide" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:sequence>
        <xs:element ref="slide" maxOccurs="unbounded"/>
    </xs:sequence>
</xs:choice>


Best Regards,
George

Return to “XML Schemas”

Who is online

Users browsing this forum: No registered users and 0 guests