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

Re: Combining maxOccurs="unbounded" with all indicator

From: George Cristian Bina <george@oxygenxml.com>
Date: Wed, 10 Nov 2004 13:55:19 +0200
Message-ID: <419201A7.1090004@oxygenxml.com>
To: Frans Englich <frans.englich@telia.com>
Cc: Xmlschema-dev <xmlschema-dev@w3.org>

Hi Frans,

Your DTD model:
(title | Action | ActionList | Separator | WeakSeparator |
TearOffHandle | Merge | MergeLocal | DefineGroup | Menu )*

in XML Schema will be:

<xsd:choice minOccurs="0" maxOccurs="unbounded">
   <xsd:element ref="title"/>
   <xsd:element ref="Action"/>
   <xsd:element ref="ActionList"/>
   <xsd:element ref="Separator"/>
   <xsd:element ref="WeakSeparator"/>
   <xsd:element ref="TearOffHandle"/>
   <xsd:element ref="Merge"/>
   <xsd:element ref="MergeLocal"/>
   <xsd:element ref="DefineGroup"/>
   <xsd:element ref="Menu"/>
</xsd:choice>

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com


Frans Englich wrote:
> 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:53:07 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 5 February 2014 23:40:23 UTC