|
[XMLSCHEMA-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Ignore Order while validating XSD
From: C. M. Sperberg-McQueen <cmsmcq@acm.org>
Date: Sun, 25 Jan 2009 17:37:55 -0700 Message-Id: <6353B072-0E12-4F14-9E1A-A03E149B22DA@acm.org> Cc: "C. M. Sperberg-McQueen" <cmsmcq@acm.org>, xmlschema-dev@w3.org To: Eduardo Oliveira <eduardo.oliveirared@gmail.com> On 24 Jan 2009, at 12:51 , Eduardo Oliveira wrote: > There´s much time since the last message, but I have a problem with > the given solution. > Since I use the model below, I can´t force the element to be > declared, or in other words, the minOccurs does not run. > > The piece of code given from "George Cristian Bina": > > <xs:complexType> > <xs:choice maxOccurs="unbounded"> > <xs:element name="a"/> > <xs:element name="b"/> > <xs:element name="c"/> > <xs:element name="x"/> > </xs:choice> > </xs:complexType> > > Suppose I wish the <xs:element name="a"/> to always be received, > so I change the code to the code below, but the minOccurs does not > run. > > <xs:complexType> > <xs:choice maxOccurs="unbounded"> > <xs:element name="a" minOccurs="1"/> > <xs:element name="b"/> > <xs:element name="c"/> > <xs:element name="x"/> > </xs:choice> > </xs:complexType> > > Does anyone has an idea how can I solve this? You want a sequence of one or more elements, which must contain at least one 'a', and may contain any number of b, c, or x elements? In a conventional regular expression, you might write (b|c|x)*, a, (a|b|c|x)* and you can do the same in XSD 1.0: <xsd:complexType name="oliveira"> <xsd:sequence> <xsd:choice minOccurs="0" maxOccurs="unbounded"> <xsd:element ref="my:b" /> <xsd:element ref="my:c" /> <xsd:element ref="my:x" /> </xsd:choice> <xsd:element ref="my:a" /> <xsd:choice minOccurs="0" maxOccurs="unbounded"> <xsd:element ref="my:a" /> <xsd:element ref="my:b" /> <xsd:element ref="my:c" /> <xsd:element ref="my:x" /> </xsd:choice> </xsd:sequence> </xsd:complexType> I hope this helps. -- C. M. Sperberg-McQueen http://cmsmcq.com/mibReceived on Monday, 26 January 2009 00:38:07 GMT |
Subscribe in XML format
|






