1

I have to validate following XML (used in thirdparty REST service) against XML Schema. There are some Key elements that are obligatory for service.

<?xml version="1.0" encoding="UTF-8"?>
<Data>
  <Details>
    <Key name="ONE"   label="a" value="11"/>
    <Key name="THREE" label="c" value="33"/>
    <Key name="TWO"   label="b" value="22"/>
  </Details>
</Data>

Is there any way (using XML Schema) to force element Details to contain all three Key elements with name attribute set to specific values, respectively ONE, TWO and THREE? No particular order of Key elements should be required.

Also additional Key elements should be possible:

<?xml version="1.0" encoding="UTF-8"?>
<Data>
  <Details>
    <Key name="ONE"   label="a" value="11"/>
    <Key name="THREE" label="c" value="33"/>
    <Key name="TWO"   label="b" value="22"/>

    <Key name ="OPTIONAL1" label="opt1" value="opt1"/>
    <Key name ="OPTIONAL2" label="opt2" value="opt2"/>
  </Details>
</Data>

Is there any chance to do it using schema? Please help!

lukk
  • 3,164
  • 1
  • 30
  • 36
  • With [xsd 1.1](http://stackoverflow.com/q/15573894/314291) you can surely do this by `assert` ing that all three attribute values are present, or, if they must be unique, that the `count` of each of the values must appear exactly once. Or better still, [`xsd:all`](http://stackoverflow.com/a/12012599/314291) – StuartLC Oct 30 '14 at 15:17

0 Answers0