W3C home > Mailing lists > Public > xmlschema-dev@w3.org > June 2008

RE: Choice of sub-element or character-data in an element

From: Michael Kay <mike@saxonica.com>
Date: Mon, 23 Jun 2008 10:06:02 +0100
To: "'Arshad Noor'" <arshad.noor@strongauth.com>, <xmlschema-dev@w3.org>
Message-ID: <32191635FAB546C5AEF0D3A3DE998398@Sealion>

You can't do this directly in XML Schema 1.0. It would be better to use
different element names for the two cases - this would make life much easier
for users of the document.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: xmlschema-dev-request@w3.org 
> [mailto:xmlschema-dev-request@w3.org] On Behalf Of Arshad Noor
> Sent: 22 June 2008 00:44
> To: xmlschema-dev@w3.org
> Subject: Choice of sub-element or character-data in an element
> 
> 
> How is it possible to define an XSD to allow an element to 
> either contain custom sub-elements, or a fixed string?
> 
> For example, I would like to be able to do the following:
> 
> <ElementA>
>     <ElementB>
>        <ElementC>Some value</ElementC>
>        <ElementD>Another value</ElementD>
>     </ElementB>
> </ElementA>
> 
> or
> 
> <ElementA>
>     <ElementB>Any</ElementB>
> </ElementA>
> 
> I'm not sure how to use <xsd:choice> to define this?  Thanks 
> for any suggestions.
> 
> Arshad Noor
> StrongAuth, Inc.
> 
> 
Received on Monday, 23 June 2008 09:06:41 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:14 UTC