XSD: ways to deal with conditionals on attribute value?

P

Piper707

Hi,

I need to generate an XML file for the result which differs based on
the value of a "status" attribute.

i.e for an error condition it would look something like this:

<result status="failure">
<errorBlock>
</result>

a success condition (an empty result block):

<result status="success">
</result>

I understand that XSD does not support conditional processing based on
the value of an attribute.

One way would be to have a tag called "failure" or "success" itself in
the body of the <result>, but then having an empty element seems
wasteful. I would like to have an atribute to do the same thing.

How does one deal with situations like these?

Thanks fo any help
Rohit.
 
Z

Zafar Abbas

You will have to write application code on top of XSD validation to process
pass/fail values of the status attribute.
You could also consider using Schematron in this situtation. XSD does not
provide any help here.
 

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
474,001
Messages
2,570,254
Members
46,850
Latest member
VMRKlaus8

Latest Threads

Top