Schema question

R

Robert Dailey

Take the following XML:


<Frame type="Image" id="frame1">
<Draw/>
</Frame>

<Frame type="Text" id="frame2">
<Print/>
</Frame>


Is there a way in Schema to specify that the "Frame" element is
different (and thus requires different child elements) depending on
the value of an attribute (specifically the "type" attribute)?
 
J

Joseph Kesselman

Robert said:
Is there a way in Schema to specify that the "Frame" element is
different (and thus requires different child elements) depending on
the value of an attribute (specifically the "type" attribute)?

Presence or absence, maybe. Value, I don't think so. Some of the other
schema(-like) languages do support that, or you can enforce that
constrating in the application code...
 
R

Robert Dailey

Presence or absence, maybe. Value, I don't think so. Some of the other
schema(-like) languages do support that, or you can enforce that
constrating in the application code...

Thank you for your reply, it was the answer I was looking for.

I would also like to ask if it's possible to make a schema accept
either of the following attribute combinations for a single element:

<Offset x="0" y="0"/>
<Offset var="myvar"/>

Is this possible?
 
U

usenet

Thank you for your reply, it was the answer I was looking for.

I would also like to ask if it's possible to make a schema accept
either of the following attribute combinations for a single element:

<Offset x="0" y="0"/>
<Offset var="myvar"/>

Is this possible?

In schema you can effectively only specify the union of the two
types. As a result things like <Offsett x="0" var="myvar"/> would
also validate. You could apply additional constraints at the
application level. XSD1.1 is due to improve onthis and Relax-NG
supports what you want.

HTH,

Pete.
--
=============================================
Pete Cordell
Codalogic Ltd
for XML Schema to C++ data binding visit
http://www.codalogic.com/lmx/
=============================================
 

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,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top