Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Best way to ensure one element out of a set

From: George Cristian Bina <george@---------.--->
To: Michael Kay <mike@--------.--->
Date: 2/13/2009 11:04:00 PM
 >     I want to make sure that at least one of the primitive_condition
 >     elements ist used, but I don't care which one.

For that you need to set minOccurs="1" on the choice from Mike's exampl=
e 
or in the group reference in your example.

Best Regards,
George
--
George Cristian Bina
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
www.---.com


Michael Kay wrote:
> You don't need the named group, you could do the following which is 
> equivalent:
>  
>     <xs:complexType name="conditions" >
>         <xs:sequence>  
>             <xs:choice minOccurs="0" maxOccurs="unbounded">
>                <xs:element name="primitive_condition_0" />
>                <xs:element name="primitive_condition_1" />
>                <xs:element name="primitive_condition_2" />
>             </xs:choice> 
> 
>             <xs:element name="complex_condition" 
> type="complex_condition" minOccurs="0" maxOccurs="unbounded" />
>         </xs:sequence>
>     </xs:complexType> 
>    
> Michael Kay
> http://www.saxonica.com/
> 
>     -------------------------------------------------------------------=
-----
>     *From:* xmlschema-dev-request@w...
>     [mailto:xmlschema-dev-request@w...] *On Behalf Of *Kl=F6ck, Erwin
>     *Sent:* 13 February 2009 15:41
>     *To:* xmlschema-dev@w...
>     *Subject:* Best way to ensure one element out of a set
> 
> 
>     Hi,
> 
>     is this the best way to ensure that one element out of a set is use=
d?
>     I have the following xml:
> 
>     --- test.xml begin ---
>     <?xml version="1.0" encoding="ISO-8859-1"?>
>     <top xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>          xsi:noNamespaceSchemaLocation="test.xsd">
>         
>          <conditions>
> 
>              <primitive_condition_0 />
>              <primitive_condition_1 />
>              <primitive_condition_2 />   
> 
>              <complex_condition />
>          </conditions>
>     </top>
>     --- test.xml end ---
> 
>     I want to make sure that at least one of the primitive_condition
>     elements ist used, but I don't care which one.
>     I have come up with the following solution (which works) but are no=
w
>     wondering if this is the best way to do this.
>     My qestion is: Is there a more straight forward way to do this than
>     to have a group of choices?
> 
>     --- test.xsd begin ---
>     <?xml version="1.0" encoding="UTF-8"?>
>     <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
>         <xs:element name="top" >
>             <xs:complexType>
>                 <xs:sequence>
>                     <xs:element name="conditions" type="conditions"=
 />
>                 </xs:sequence>
>             </xs:complexType>
>         </xs:element>
>        
>         <xs:complexType name="conditions" >
>             <xs:sequence>
>                 <xs:group ref="primitive_conditon" minOccurs="0"
>     maxOccurs="unbounded" />
>                 <xs:element name="complex_condition"
>     type="complex_condition" minOccurs="0" maxOccurs="unbounded" =
/>
>             </xs:sequence>
>         </xs:complexType>
>        
>         <xs:group name="primitive_conditon" >
>             <xs:choice>
>                 <xs:element name="primitive_condition_0" />
>                 <xs:element name="primitive_condition_1" />
>                 <xs:element name="primitive_condition_2" />
>             </xs:choice>
>         </xs:group>
>        
>         <xs:complexType name="complex_condition" />
>     </xs:schema>
>     --- test.xsd end ---
> 
>     Thanks for taking an interest.
> 
>     Erwin
> 

From kbraun@o... Sat Feb 14 14:32:44 2009
Received: from farnsworth.w3.org ([128.30.52.43] helo=wiggum.w3.org)
	by frink.w3.org with esmtp (E


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent