I’m trying to write an XSD schema in which some elements can appear in any order – but there can be no duplicates.
So this is valid:
<parent>
<my-element-A>1</my-element-A>
<my-element-B>2</my-element-B>
<my-element-C>3</my-element-C>
</parent>
… and this is valid:
<parent>
<my-element-B>2</my-element-B>
<my-element-A>1</my-element-A>
<my-element-C>3</my-element-C>
</parent>
But this is not:
<parent>
<my-element-A>1</my-element-A>
<my-element-B>2</my-element-B>
<my-element-A>1</my-element-A><!-- Fail! Duplicate my-element-A -->
<my-element-C>3</my-element-C>
</parent>
How can I do this with XSD?
The
<xs:all>element defines “A grouping of a sequence is a set of sub-sequences, some or all of which may be empty, such that each member of the original sequence appears once and only once in one of the sub-sequences and all members of all sub-sequences are in the original sequence.”