W3C home > Mailing lists > Public > www-ql@w3.org > October to December 2001

Re: how to express union in XQuery

From: Jose Maria Sanchez Saez <jmss@gssi.es>
Date: Thu, 1 Nov 2001 15:40:49 +0100
To: www-ql@w3c.org
Message-Id: <01110115404900.13302@jmss.gssi.es>
> 	Can anybody tell me how can I express union in XQuery ?
> 	Thanks in advance.

In http://www.w3.org/TR/xmlschema-1/index.html#Model_Groups you can see this 
text.

> 3.8.1 The Model Group Schema Component
>
> The model group schema component has the following properties:

> Schema Component: Model Group
> {compositor}
>       One of all, choice or sequence. 
> {particles}
>       A list of particles 
> {annotation}
>       Optional. An annotation.
>
> specifies a sequential (sequence), disjunctive (choice) or conjunctive
> (all) interpretation of the {particles}. This in turn determines whether 
> the element information item [children] ·validated· by the model group must:
>
>    * (sequence) correspond, in order, to the specified {particles};
>    * (choice) corresponded to exactly one of the specified {particles};
>    * (all) contain all and only exactly zero or one of each element 
>        specified in {particles}. The elements can occur in any order. In 
>        this case, to reduce implementation complexity, {particles} is 
>        restricted to contain local and top-level element declarations only, 
>         with {min occurs}=0 or 1, {max occurs}=1.

You are asking for the compositor <choice>. 

If you would use 
<element name="myelement">
  <complexType>
     <sequence>
        <element name="el1" type="string"/>
        <element name="el3" type="string"/>
        <element name="el4" type="string"/>
     </sequence>
  </complexType>
</element>

to make appear all of elements el1, el2 and el3 in myelement, with

<element name="myelement">
  <complexType>
     <choice>
        <element name="el1" type="string"/>
        <element name="el3" type="string"/>
        <element name="el4" type="string"/>
     </choice>
  </complexType>
</element>

just one of then could be in the element myelement.

I hope to be right and it help you :-)
Received on Thursday, 1 November 2001 08:42:19 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 22 July 2006 00:10:18 GMT