RE: allowing zero to unbounded elements in any order?

Jeni,

Unfortunately, the group of elements is actually in the range of 50
different elements.  Having one permutation for each combination would be
counter-productive, so I'm afraid I couldn't utilize your 1st suggestion.

I am bound by using straight xsd, without any other utilities.  I'm not sure
what you refer to as a loose content model, but if there are extra tags of
anything other than <C>, that could cause some extreme problems.  The XML
code is being used in recipe creation, where a recipe is what populates a
particular component in our software.  So, while Schematron sounds cool, I'm
afraid I can't use it.

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.

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

Thanks, Jeni,

Michael

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


Hi Michael,

> I had a case where I needed to do this as well. Your solution is
> intriguing, but I'm confused. What if I wanted a list similar to :
>
>         <A>
>                 <B/>
>                 <C/>
>                 <D/>
>                 <E/>
>                 <C/>
>         </A>
>
> Where I could have multiple copies of <C/>, but I wanted to allow B,
> C, D, and E to be any order. After a few days of trying to
> accomplish that, I gave up, and used <xs:sequence> instead, and
> force my users to live with order.

Yes, that's one of the ways to handle the problem. If you were kind,
you might supply a simple transformation that would generate the order
you've specified in the schema from the order that they've used in
their document. The other ways are:

  - create a content model that tediously spells out the possible
    alternative orderings

  - use a loose content model in which everything can repeat any
    number of times and then use Schematron (or something similar) to
    add the constraint that B, D and E can appear only once

  - add a wrapper around the repeatable C element, so that you can use
    <xs:all> to get B, C, D and E to appear in any order
    
  - switch to RELAX NG, where it's easy to express using interleave:
    (B & C+ & D & E)

Cheers,

Jeni

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

Received on Friday, 14 March 2003 13:52:49 UTC