W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2010

Re: Conditional type definition

From: Pete Cordell <petexmldev@codalogic.com>
Date: Wed, 10 Mar 2010 16:37:33 -0000
Message-ID: <5CDD73C35BDE48679A2445B4F2028B83@Codalogic>
To: "Ralph Kutschera" <news2010@ecuapac.at>, <xmlschema-dev@w3.org>
Apologies for responding to my own e-mails, but...

You can also define anElement to be an xs:choice so you can do:

<anElement>
   <ONEelement />
</anElement>

<anElement>
   <TWOelement />
</enElement>

Potentially the type attribute is redundant.

HTH,

Pete Cordell
Codalogic Ltd
Interface XML to C++ the easy way using XML C++
data binding to convert XSD schemas to C++ classes.
Visit http://codalogic.com/lmx/ or http://www.xml2cpp.com
for more info
----- Original Message ----- 
From: "Pete Cordell" <petexmldev@codalogic.com>
To: "Ralph Kutschera" <news2010@ecuapac.at>; <xmlschema-dev@w3.org>
Sent: Wednesday, March 10, 2010 4:27 PM
Subject: Re: Conditional type definition


>
> Hi Ralph,
>
> You can't do conditional type assignment with XSD 1.0.  The upcoming XSD 
> 1.1
> will allow conditional type assignment but that is still work in progress.
>
> The closest you can get in XSD 1.0 is to put the conditionality into an
> xs:choice of possible elements so you have:
>
> <aTypeOneElement>
>   <ONEelement />
> </aTypeOneElement>
>
> <aTypeTwoElement>
>   <TWOelement />
> </aTypeTwoElement>
>
> Or define a type that is allows both ONEElement and TWO element and check
> the constraint at the application level.
>
> HTH,
>
> Pete Cordell
> Codalogic Ltd
> Interface XML to C++ the easy way using XML C++
> data binding to convert XSD schemas to C++ classes.
> Visit http://codalogic.com/lmx/ or http://www.xml2cpp.com
> for more info
>
> ----- Original Message ----- 
> From: "Ralph Kutschera" <news2010@ecuapac.at>
> To: <xmlschema-dev@w3.org>
> Sent: Wednesday, March 10, 2010 3:44 PM
> Subject: XSD: Conditional type definition
>
>
>>
>> Dear list,
>>
>>   I'm relatively new to XSD and would like to perform the following:
>>
>>
>> I have an XML-element like this:
>> <anElement type="ONE">
>>   <ONEelement />
>> </anElement>
>>
>> <anElement type="TWO">
>>   <TWOelement />
>> </enElement>
>>
>> So there is the "anElement" and depending on its type the subelements are
>> different. Is there a way to declare this behaviour with XSD?
>>
>> TIA,
>>   Ralph
>>
>>
>>
>
>
>
>
> 
Received on Wednesday, 10 March 2010 16:38:28 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:15:19 GMT