← Prev in month ← Prev in thread

Re: [xml-dev] Unrestricted order and cardinality?

From
Marielou <>
To
Eric van der Vlist <>,
Date
2006-06-21T13:21:08Z
ID
<>
Thread
Re: [xml-dev] Unrestricted order and 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 <> 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
← Prev in month ← Prev in thread