Altova Mailing List Archives>Archive Index >xmlschema-dev Archive Home >Recent entries >Thread Prev - Re: Ignore Order while validating XSD >Thread Next - Re: Ignore Order while validating XSD Re: Ignore Order while validating XSDTo: Eduardo Oliveira <eduardo.oliveirared@-----.---> Date: 1/25/2009 10:38:00 AM
On 24 Jan 2009, at 12:51 , Eduardo Oliveira wrote:
> There=B4s much time since the last message, but I have a problem with =
> the given solution.
> Since I use the model below, I can=B4t 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/mib
From philip.aker@s... Mon Jan 26 09:20:18 2009
Received: from farnsworth.w3.org ([128.30.52.43] helo=w | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
