views:

31

answers:

1

A simple scenario: if one field contains "A", then the other field should not contain "B". How to write a XSD schema for it. Example:

<root>
<field_1>A</field_1>
<field_2>B</field_2>
</root>

How to write an XSD schema that imposes restriction on the value of an element, depending on the value of another element?

+1  A: 

You cannot do this in XML Schema 1.0 - you need to look elsewhere, like at Schematron or Relax NG for those kinds of validations.

marc_s
thanks. The answer is sad, but seem to be true.
fedor
why is xsd schema such weak?
fedor
Because it is designed for linear-time front-to-back validation, so it can be used with streams. The only thing that violates that are the key/keyref rules, and these usually need to be activated separately for that reason.
xcut