Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restrict exclusive key-value pairs in XSD

Tags:

xml

xsd

In the XSD, there are two elements, A and B. They are siblings.

A can have a value of either "1" or "2". B can have a value of either "one" or "two".

I want to restrict this, however, so that only "1-one" and "2-two" are valid combinations, not "1-two" or "2-one". Is there a way of doing that in the XSD?


1 Answers

Schematron can be used to define such co-occurrence constraints. You can find some introductory articles here:

  • Improving XML Document Validation with Schematron
  • Schematron: XML Structure Validation Language Using Patterns in Trees
like image 111
Dirk Vollmar Avatar answered Nov 20 '25 15:11

Dirk Vollmar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!