Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

complex type schema

0 views
Skip to first unread message

moto...@gmail.com

unread,
Oct 22, 2007, 2:40:38 PM10/22/07
to
Hi,

I am a newbie to schema definitions so forgive me if this is a simple
question.

I am trying to create a schema for a complex type that allows
instances of either of the two forms:

<test1 state=true>
<name>test1/>
<type>typeA/>
</test1>

<test2 state=false>
<name>test2/>
<type>type@/>
</test2>

Here the 'type' element is a string without the '@' character if
'state' is true and a string with the '@' character when state is
false.

Joseph Kesselman

unread,
Oct 22, 2007, 3:21:30 PM10/22/07
to
moto...@gmail.com wrote:
> I am trying to create a schema for a complex type that allows
> instances of either of the two forms:
>
> <test1 state=true>
> <name>test1/>
> <type>typeA/>
> </test1>
>
> <test2 state=false>
> <name>test2/>
> <type>type@/>
> </test2>

XML Schemas don't allow you to select between two different types of
content based on the value of a variable -- *EXCEPT* by making the two
types of content subtypes of a single type, and then using the xsi:type
attribute to switch between them. If you are willing to replace your
"state" with that directive, you can make this work. Otherwise, do this
cross-dependency check in your application code, or investigate whether
your environment supports any of the other schema languages.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden

jasont...@googlemail.com

unread,
Oct 23, 2007, 4:23:44 AM10/23/07
to
I'm just starting to get my head around XML Schemas. I found XML
Studio really good for learning the basics, and its free

http://www.liquid-technologies.com/Product_XmlStudio.aspx

Regards Jason

0 new messages