Defining different elements in XML Schema

F

fulvio.risso

Hello guys.

I would like to use the following two types of elements in my XML file:

<field type="fixed" size="10"/>
<field type="variable" expr="a+b"/>

The problem is that I cannot find a way to define the proper XML
schema. The problem is that I would like to define an element
("<field>") which may have different syntax according to the value of
one of its attribute. It seems to me that a solution is to use
"xsi:type=..." in the XML file, but I don't want to do that.

Does anybody have a solution for this (maybe stupid) problem?

Cheers,

fulvio
 
S

Soren Kuula

Does anybody have a solution for this (maybe stupid) problem?

Hi,

The stupid one is not you..

You can't specify the dependence of anything on attribute values in XML
Schema.

Relax NG can do it, and it's a much nicer language to work with (my
opinion anyway).

Soren
 
S

Stan Kitsis [MSFT]

Can you use this instead?

<fields>
<fixed size="10"/>
<variable expr="a+b"/>
</fields>

--
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Priscilla Walmsley

Hi,

Just out of curiosity, why don't you want to use xsi:type? It's a
simple matter of adding a namespace declaration in your document, and
prefix to your type attributes:

<field xsi:type="fixed" size="10"/>
<field xsi:type="variable" expr="a+b"/>

Priscilla
 

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,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top