complex type schema

M

motorpage

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.
 
J

Joseph Kesselman

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,828
Latest member
LauraCastr

Latest Threads

Top