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 XSDTo: "C. M. Sperberg-McQueen" <cmsmcq@---.---> Date: 1/26/2009 7:55:00 AM Hello Mr. Sperberg-McQueen!
That=B4s ok! Your solution run as I expected it to run!
I just took the freedom to make a little change to reduce the code size,
setting the element "a"=B4s maxOccurs="unbounded", eliminating the second
block as below!
Thanks a lot!
Eduardo
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="root">
<xs:complexType >
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="b"/>
<xs:element name="c"/>
<xs:element name="x"/>
</xs:choice>
<xs:element name="a" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
2009/1/25 C. M. Sperberg-McQueen <cmsmcq@a...>
>
> On 24 Jan 2009, at 12:51 , Eduardo Oliveira wrote:
>
> There=B4s much time since the last message, but I have a problem with th=
e
>> 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
>
>
>
>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
