[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Unrestricted order and cardinality?

  • To: Eric van der Vlist <vdv@d...>, xml-dev@l...
  • Subject: Re: Unrestricted order and cardinality?
  • From: Marielou <marielou_h@y...>
  • Date: Wed, 21 Jun 2006 14:21:08 +0100 (BST)
  • Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.uk; h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=ui+ektnLqqPk7XvLDO5TfpqGXbqZoHNp5EG19X8eVt5khl34fcUyPM6czz4D8n4LyZo44EtqI/uAeulir5jlOmRG5886kQzXjcQvOtLATteQaQP6Dcg1uxRoicb2qRqLIH80JM6El2gIUhNBh6OZkiSF8HeN/KFtzYMIlAZ5sCg= ;
  • In-reply-to: <1150884579.5966.6.camel@l...>

xml cardinality
Funny thing is, the description used to be written in
a DTD, but my boss now wants a schema! 

When I use <choice> in a schema, I find it works when
all element occurrences are unrestricted, but I have
several child elements to describe each with different
cardinality, all are unrestricted in the order. So I
tried with maxOccurs="unbounded" on the <choice> and a
limit on the elements but I find that the maxOccurs on
the <choice> takes priortiy over element occurrences
so maxOccurs e.g below

<xs:element name="parentA">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="childB" minOccurs="1" maxOccurs="1"/>
<xs:element ref="childC"  minOccurs="1"
maxOccurs="7"/>
<xs:element ref="childD" minOccurs="1" maxOccurs="4"/>
<xs:element ref="childE" minOccurs="1"
maxOccurs="unbounded"/>
...
</xs:choice>
</xs:complexType>
</xs:element>

lets all elements occur unbounded and ignores that
e.g. B should only occur 1x. If I remove "unbounded"
from the <choice>, I cant get past the first element! 

Marie Louise






--- Eric van der Vlist <vdv@d...> wrote:

> Le mercredi 21 juin 2006 à 05:52 -0400, Frank
> Richards a écrit :
> > Marielou wrote:
> > > Is it possible to have unrestricted order and
> > > unrestricted cardinality? the options <all>
> <sequence>
> > > and <choice> dont make this easy. I have
> implemented
> > > my schema using <sequence> to enable me to
> achieve the
> > > unrestricted cardinality I require but this is
> not
> > > what I need as each XML I am validating has a
> > > different order. Is there some pattern i can use
> in my
> > > schema to combine elements to achieve
> unrestricted
> > > order and unrestricted cardinality? is there
> some
> > > (probably )complex design which could get round
> the
> > > limitations? please help! even if the answer is
> a
> > > known "no this is most definately not possible
> with
> > > the restrictions on XML schema please confirm!"
> > >
> > >   
> > I suppose it's cheating to suggest using a DTD:
> > 
> > <!ELEMENT foo (bar | baz )*>
> 
> Which in W3C XML Schema is spelled:
> 
> <xs:element name="foo">
>     <xs:complexType>
>         <xs:choice minOccurs="0"
> maxOccurs="unbounded">
>             <xs:element ref="bar"/>
>             <xs:element ref="baz"/>
>         </xs:choice>
>     </xs:complexType>
> </xs:element>
> 
> Eric
> 
> -- 
> GPG-PGP: 2A528005
> Have you ever thought about unit testing XSLT
> templates?
>                                                     
> http://xsltunit.org
>
------------------------------------------------------------------------
> Eric van der Vlist       http://xmlfr.org           
> http://dyomedea.com
> (ISO) RELAX NG   ISBN:0-596-00421-4
> http://oreilly.com/catalog/relax
> (W3C) XML Schema ISBN:0-596-00252-1
> http://oreilly.com/catalog/xmlschema
>
------------------------------------------------------------------------
> 



	
	
		
___________________________________________________________ 
All new Yahoo! Mail "The new Interface is stunning in its simplicity and ease of use." - PC Magazine 
http://uk.docs.yahoo.com/nowyoucan.html

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.