Re: Combining maxOccurs="unbounded" with all indicator

On Monday 01 November 2004 13:26, Jeni Tennison wrote:
> Hi Frans,
>
> > How do I achieve this -- allow multiple unbounded elements to be
> > freely mixed with each others and simple elements?
>
> This is probably the most frequent of FAQs.
>
> DTDs have a similar restriction, and the traditional approach is to
> define the model using something like:
>
>   ((include | group)*, kcfgfile, (include | group)*)

I have a similar problem again, but this time a DTD expression validates for 
it. It looks like this:

<!ELEMENT Menu (title | Action | ActionList | Separator | WeakSeparator | 
TearOffHandle | Merge | MergeLocal | DefineGroup | Menu )*>


My DTD knowledge is smaller than what I know about XML Schema, but to me that 
reads like Menu may contain zero or more of those listed items, in any order.

I tried to replicate it in XML Schema(snipped and compacted):

<xsd:element name="Menu">
<xsd:complexType>
    <xsd:all>
        <xsd:element minOccurs="0" name="title" type="caption" />

        <xsd:element ref="Action" maxOccurs="unbounded" />
        <xsd:element ref="ActionList" maxOccurs="unbounded" />

        <xsd:element minOccurs="0" maxOccurs="unbounded" name="TearOffHandle">
        </xsd:element>

        <xsd:element minOccurs="0" maxOccurs="unbounded" name="DefineGroup">
        </xsd:element>

        <xsd:element minOccurs="0" maxOccurs="unbounded" name="MergeLocal">
        </xsd:element>

        <xsd:element minOccurs="0" maxOccurs="unbounded" ref="Separator" />
        <xsd:element minOccurs="0" maxOccurs="unbounded" 				 
ref="WeakSeparator" />
        <xsd:element minOccurs="0" maxOccurs="unbounded" ref="Menu" />
        <xsd:element minOccurs="0" maxOccurs="unbounded" name="Merge" />
    </xsd:all>


This obviously doesn't work since 'all' indicator and maxOccurs="unbounded" is 
combined, but it illustrates what I want. Is it impossible to express such 
constructs, which works in DTD, in XML Schema, or have I missed something?


Cheers,

		Frans

Received on Wednesday, 10 November 2004 11:05:33 UTC