RE: allowing zero to unbounded elements in any order?

Jeni,

I'm confused. Isn't the 

	"minOccurs=0"

just what is telling the schema that this particular element that it's
optional?

Michael

 -----Original Message-----
From: 	Jeni Tennison [mailto:jeni@jenitennison.com] 
Sent:	Friday, March 14, 2003 4:04 PM
To:	Scott, Michael Gordon
Cc:	Sam Carleton; xmlschema-dev
Subject:	Re: allowing zero to unbounded elements in any order?

Hi Michael,

> I am bound by using straight xsd, without any other utilities. I'm
> not sure what you refer to as a loose content model,

One in which you have a zero-or-more choice between all the elements
that can be present, meaning that they can all be present in any
order, any number of times. It's loose in that it allows more than you
actually want to allow.

> I tried your 3rd alternative, but unsuccessfully. Being relatively
> new to schema's, I could have just missed something. Here is an
> example of what I'm doing now, with <xsd:sequence> :
>
>         <xsd:complexType name="Type_LotSummary">
>                 <xsd:complexContent>
>                         <xsd:extension base="Type_ToolLotSummary">
>                                 <xsd:sequence minOccurs="0" maxOccurs="1">
>                                         <xsd:element name="NumWafers"
> type="xsd:nonNegativeInteger" minOccurs="1" maxOccurs="1"/>
>                                         <xsd:element name="Wafers"
> type="WaferLocations" minOccurs="1" maxOccurs="1"/>
>                                 </xsd:sequence>
>                         </xsd:extension>
>                 </xsd:complexContent>
>         </xsd:complexType>
>
>         <xsd:complexType name="WaferLocations">
>                 <xsd:sequence minOccurs="0" maxOccurs="1">
>                         <xsd:element name="WaferLoc"
> type="xsd:normalizedString" minOccurs="0" maxOccurs="unbounded"/>
>                 </xsd:sequence>
>         </xsd:complexType>
>
> Where <Type_ToolLotSummary> contains about 40 different element
> tags, that my users want to be in any order (as well as some being
> optional), as well as <NumWafers> and <Wafers>, which contains one
> or more <WaferLoc> tags. Once I replaced <xsd:sequence> with
> <xsd:all>, a cascading waterfall of problems started popping up.

Hmm... you should be able to replace the <xs:sequence> with an
<xs:all> (you need to get rid of the minOccurs="0", though). As long
as the <xs:all> appears exactly once and only contains elements that
appear zero-or-one times, then you should be fine.

> I'm just assuming that it isn't possible with straight xsd.

That's very possible. It's easy to get to the limits of XML Schema's
support for elements-in-any-order.

Cheers,

Jeni

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

Received on Friday, 14 March 2003 21:00:01 UTC