Timofey
Timofey

Reputation: 2508

Validate specific XML with XSD

We have specific XML that has specific structure:

<root>
  <element type=”a”>
    <value>someValueA</value>
  </element>
  <element type=”b”>
    <value>someValueB</value>
  </element>
</root>

Is it possible to validate it using XSD in such a way that the element with type “a” is required and that of type “b” is not required?

Upvotes: 1

Views: 255

Answers (1)

Michael Kay
Michael Kay

Reputation: 163262

In XSD 1.0 you can't apply different constraints to different sibling elements that have the same element name.

It looks like you need XSD 1.1 assertions - available now in Saxon and Xerces.

Upvotes: 1

Related Questions