Page 1 of 1

conditional validation based on an attribute

Posted: Mon Mar 27, 2006 11:37 pm
by RobertB

Does anybody know of an easy way in a XSD to have a validation based on an attribute from the parent node ?

<product no="218">
<part type="é" />
<product no="205">
<part type="é">

In the XSD:
<xs:element name="participant" minOccurs="0" maxOccurs="1">
<xs:element name="part" minOccurs="1" maxOccurs="12">

The tag participant can only occur if the product no is 205, and the maxOccurs of product no 218 is 12 where is really is 10 for product no 205.

How can I do this ? I really need both to be under the "product tag", so I cannot change its name.

Thank's for help !

Posted: Tue Mar 28, 2006 6:34 am
by george
Hi Robert,

What you want is called cooccurence constraint and XML Schema does not support this. You can use Schematron embedded rules inside XML Schema that oXygen supports to check for your constraints or check them at application level.
See for a similar example, you have there an XML Schema with schematron embedded rules.

Best Regards,

To George

Posted: Tue Mar 28, 2006 5:01 pm
by RobertB
Thank's for your time, this is what I thought !