Re: Conditional type definition

"Pete Cordell" <[email protected]>
Newsgroups gmane.text.xml.schema.devel
Message-ID <0C7FE874D5834E8B9FEEA25C65616691@Codalogic>
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" <[email protected]>
To: <[email protected]>
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
>
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.