Page 1 of 1

Checks and Constraints with XML Schema?

Posted: Thu May 19, 2005 12:24 pm
by Juergen.Birkle
Hi,

I have the following 2 XML files:
-----
<test>
<type>car</type>

<vehicle>BMW</vehicle>
<vehicle>Audi</vehicle>
<vehicle>Rover</vehicle>
</test>
-----
and:
-----
<test>
<type>motorbike</type>

<vehicle>Honda</vehicle>
<vehicle>Kawasaki</vehicle>
</test>
-----
Is it possible to check the value of 'type' to restrict the possible values of 'vehicle' with XML Schema?

I'd like XML Schema to accept only the values 'BMW', 'Audi' and 'Rover' (and other out of a list) if the type is set to 'car' and different values, if the type is set to 'motorbike'.


Thanks for any help.

Regards,
Juergen

Posted: Fri May 20, 2005 4:22 pm
by george
Hi Juergen,

This is generally called coocurance constraint and it is not possible with XML Schema alone.
Your example can be handled with XML Schema plus Schematron for instance or with Relax NG. All these are supported by oXygen.

Best Regards,
George