logo       

Re: Combining maxOccurs="unbounded" with all indicator: msg#00059

text.xml.schema.devel

Subject: Re: Combining maxOccurs="unbounded" with all indicator


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





<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise