[
Lists Home |
Date Index |
Thread Index
]
- To: Eric van der Vlist <vdv@dyomedea.com>, xml-dev@lists.xml.org
- Subject: Re: [xml-dev] Unrestricted order and cardinality?
- From: Marielou <marielou_h@yahoo.co.uk>
- 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@localhost.localdomain>
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@dyomedea.com> 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
|