?
Solved

XSD - mutual exclusion based on selection (if/else)

Posted on 2009-02-23
2
Medium Priority
?
1,386 Views
Last Modified: 2012-05-06
What I want to do in my XSD is have a choice of elements based on a previously selected element value to ensure that validation takes place properly (as there is only a single, special case for the element which I want to create).

The logic would be something like:

<A>value1</A> then only <B> can follow
<A>value2</A> then only <C> can follow
<A>value2</A> then only <C> can follow
...
<A>valueN</A> then only <C> can follow

So the "code" section would contain three valid schema definitions.

How would I do this?
<root>
  <A>value1</A>
  <B>whatever</B>
</root>
 
 
<root>
  <A>value2</A>
  <C>some other data type</C>
</root>
 
 
<root>
  <A>valueN</A>
  <C>some other data type</C>
</root>

Open in new window

0
Comment
Question by:revof11_
1 Comment
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 2000 total points
ID: 23714543
This is a co-occurence constraint and can not be expressed by W3C Schema 1.0
There is an assert extension to schem (in W3C SChema 1.1) but as far as I know that is only supported by Saxon as of now.
You should use a layered validation approach with your schema in combination with www.schematron.com
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question