- From: Scott, Michael Gordon <Michael.Gordon.Scott@kla-tencor.com>
- Date: Fri, 14 Mar 2003 10:05:48 -0800
- To: "'Jeni Tennison'" <jeni@jenitennison.com>, Sam Carleton <sam@linux-info.net>
- Cc: xmlschema-dev <xmlschema-dev@w3.org>
Jeni, 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. Michael Scott KLA-Tencor, Defect Yield Solutions Division -----Original Message----- From: Jeni Tennison [mailto:jeni@jenitennison.com] Sent: Friday, March 14, 2003 4:30 AM To: Sam Carleton Cc: xmlschema-dev Subject: Re: allowing zero to unbounded elements in any order? Hi Sam, > I am trying to define a element that contains text and can > optionally contain one or more <b> elements and/or <i> elements in > any order. How do I define that? This is what I have so far: > > <xs:complexType name="stringType" mixed="true"> > <xs:all minOccurs="0"> > <xs:element ref="b"/> > <xs:element ref="i"/> > </xs:all> > </xs:complexType> > <xs:element name="i" type="xs:string"/> > <xs:element name="b" type="xs:string"/> You can't use <xs:all> for repeatable elements, but a repeating <xs:choice> works nicely. Try: <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element ref="b" /> <xs:element ref="i" /> </xs:choice> for zero to unbounded (as per the subject line of your email) or: <xs:choice maxOccurs="unbounded"> <xs:element ref="b" /> <xs:element ref="i" /> </xs:choice> for one to unbounded (as per the text of your email). Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/
Received on Friday, 14 March 2003 13:06:06 UTC