Consider two possible implementations of a "tag group":
Authors are allowed to use either an element named <tag-group>
or any element with attribute role="tag-group"
.
I'd like to write an XSD schema that will validate either case.
Ideally, the schema can also validate that children are valid within a given parent. The "tag group", for example, allows children to be either an element named <tag>
or any element with attribute role="tag"
.
So the ideal schema would validate, that given <tag-group>
, the child should be <tag>
; OR given any element with role="tag-group"
, the child should be any element with role="tag"
.
Test case expectations:
PASS
<tag-group>
<tag>foo</tag>
</tag-group>
PASS
<foo role="tag-group">
<bar role="tag">fum</bar>
</foo>
FAIL
<tag-group>
<bar role="tag">fum</bar>
</tag-group>
FAIL
<foo role="tag-group">
<tag>foo</tag>
</foo>
I am new to XSD and happy to look through reference docs if you link them.