Checks and Constraints with XML Schema?

This should cover W3C XML Schema, Relax NG and DTD related problems.
Juergen.Birkle
Posts: 1
Joined: Thu May 19, 2005 12:18 pm

Checks and Constraints with XML Schema?

Post by Juergen.Birkle » Thu May 19, 2005 12:24 pm

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

george
Site Admin
Posts: 2101
Joined: Thu Jan 09, 2003 2:58 pm

Post by george » Fri May 20, 2005 4:22 pm

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

Post Reply