W3C home > Mailing lists > Public > xmlschema-dev@w3.org > November 2004

Re: Combining maxOccurs="unbounded" with all indicator

From: Frans Englich <frans.englich@telia.com>
Date: Wed, 10 Nov 2004 11:12:32 +0000
To: "Xmlschema-dev" <xmlschema-dev@w3.org>
Message-Id: <200411101112.32184.frans.englich@telia.com>

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: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 minOccurs="0" maxOccurs="unbounded" name="DefineGroup">

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

        <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" />

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?


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

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:06 UTC