[XMLSCHEMA-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: xs:choice question

From: Pete Cordell <petexmldev@tech-know-ware.com>
Date: Thu, 28 Jun 2007 12:15:39 +0100
Message-ID: <002301c7b975$ab101aa0$e000a8c0@Codalogic>
To: "Markus Gamperl" <markus.gamperl@gmx.at>, <xmlschema-dev@w3.org>
Re: xs:choice question

I think you can change this to the following and get what you want:

 <xs:choice>
 <xs:sequence>
   <xs:element name="a" type="xs:string"/>
   <xs:element name="b" type="xs:string" minOccurs="0"/>
 </xs:sequence>
 <xs:element name="b" type="xs:string"/>
 </xs:choice>

The strategy works for simple cases like this, but doesn't extend well to 
having more elements that have to share the same sort of occurrence 
constraints.  This is an area that future schema recommendations are looking 
at.

HTH,

Pete.
--
=============================================
Pete Cordell
Codalogic Ltd
for XML Schema to C++ data binding visit
 http://www.codalogic.com/lmx/
=============================================

----- Original Message ----- 
From: "Markus Gamperl" <markus.gamperl@gmx.at>
To: <xmlschema-dev@w3.org>
Sent: Wednesday, June 27, 2007 8:21 PM
Subject: xs:choice question


>
> Hello!
>
> I have the following xml fragment example:
>
> <data>
> <a>a test</a>
> <b>b test</a>
> <data>
>
> the schema should check the following rules (three options):
> - element a must exist, b may not
> - element b must exist, a may not
> - element a and b must exist
>
> Therefor I have defined the following choice:
> ...
> <xs:choice>
> <xs:element name="a" type="xs:string"/>
> <xs:element name="b" type="xs:string"/>
> <xs:sequence>
>   <xs:element name="a" type="xs:string"/>
>   <xs:element name="b" type="xs:string"/>
> </xs:sequence>
> </xs:choice>
> ...
>
> The xml editor raises an error - something about non determenistic 
> declaration...
>
> Do you have a suggestion how to define these three rules?
>
> Thanks for your help!
> Markus
> -- 
> Psssst! Schon vom neuen GMX MultiMessenger gehört?
> Der kanns mit allen: http://www.gmx.net/de/go/multimessenger
>
> 
Received on Thursday, 28 June 2007 11:16:15 GMT

Subscribe to the Stylus Scoop newsletter for helpful XML tips and tutorials.
Email
First Name
Last Name
Company

Download Stylus Studio 6 XML Enterprise Edition

Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.