Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Problem with sequence inside a group

From: Jeni Tennison <jeni@------------.--->
To: "Simon Kampa" <simon.kampa@------.--.-->
Date: 7/23/2004 5:43:00 PM
Hi Simon,

> Xerces 2.5.2 complains at my schema when a sequence (directly under
> a group declaration) has cardinality values (see Listing 1). To me
> this appears to be a bug within the schema parser. What do you lot
> think?

Xerces is correct. The particles directly within a <xs:group>
definition must not have occurrence constraints on them: those should
instead be specified on the *reference* to the group.

(Don't ask me why this is so, it just is.)

> As a work-around, I simply added a choice around the sequence
> (Listing 2) and it works.

Yeah, crazy innit. The correct "workaround" is to have:

<xs:group name="MenuGroup">
  <xs:sequence>
    <xs:element ref="Menu" minOccurs="0" maxOccurs="unbounded"/>
    <xs:element ref="Separator" minOccurs="0" maxOccurs="unbounded"/>
    <xs:element ref="Action" minOccurs="0" maxOccurs="unbounded"/>
  </xs:sequence>
</xs:group>

and then, whenever you use the group to have:

  <xs:group ref="MenuGroup" minOccurs="0" maxOccurs="unbounded" />

  
BTW, the usual pattern for a content model in which any of the
elements can appear, in any order, any number of times, would be to
use a <xs:choice> rather than a <xs:sequence> and remove the
occurrence constraints from the individual element particles, as in:

<xs:group name="MenuGroup">
  <xs:choice>
    <xs:element ref="Menu" />
    <xs:element ref="Separator" />
    <xs:element ref="Action" />
  </xs:choice>
</xs:group>

In other words, rather than having:

  (Menu*, Separator*, Action*)*

you'd have:

  (Menu | Separator | Action)*

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

From rschloss@u...  Mon Jul 26 02:12:51 2004
Return-Path: <rschloss@u...>
X-Ori


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent