Trying to define multi-level enumeration restrictions

This should cover W3C XML Schema, Relax NG and DTD related problems.
vernon
Posts: 1
Joined: Tue Nov 01, 2005 12:47 am

Trying to define multi-level enumeration restrictions

Post by vernon » Tue Nov 01, 2005 12:57 am

Hi all,

I have XML as follows:

<FieldConfig Group="MAIN" FieldName="OrderNumber"/>
<FieldConfig Group="MAIN" FieldName="Customer"/>
<FieldConfig Group="MAIN" FieldName="Address"/>
<FieldConfig Group="DETAIL" FieldName="Customer"/>
<FieldConfig Group="DETAIL" FieldName="JobDesc"/>
etc.

What I want to do is restrict the FieldName attribute to a different set of values for each possible Group value.

For example, valid Group values are: MAIN, DETAIL, PAYMENT.
In Group MAIN, valid FieldName values are OrderNumber, Customer, Address, Phone.
In Group DETAIL, valid FieldName values are Customer, StartDate, JobDesc.

What is the best way to set up the restrictions in the XSD? Thanks in advance,

Vernon

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

Post by george » Tue Nov 01, 2005 11:05 am

Hi Vernon,

These are called co-occurance constraints and are not supported by XML Schema. You have as options:
* enforce them at application level
* use XML Schema with Schematron embedded rules (oXygen supports this and you can even validate against both the XML Schema and the Schematron rules in one action).
* use Relax NG schemas

Best Regards,
George

Post Reply