Same element, multiple types with XML Schema
I want to build the following XML:
<?xml version="1.0"?>
<foo>
<bar type="alpha">
<first />
<second />
</bar>
<bar type="bravo">
<third />
<fourth />
</bar>
</foo>
The essential point is that I want the "bar" to have different children depending on its type - if the type is "alpha" then the children MUST be "first" and "second", and if the type is bravo "then the children MUST be “third” and “fourth.” XSD validators seem to dislike the idea of the same element as two different sets of rules.
How do I create an XML schema document to enforce this rule?
0
a source to share
1 answer
Unfortunately you cannot do this with XDS, see the cos-element-consistent schema component limitation . You can either change the content model as a workaround, or use eg. Relax NG that will allow it.
+1
a source to share