OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   Schema validation question

[ Lists Home | Date Index | Thread Index ]

I have been out of the XML world for a little while now, but someone just asked me a question and I have to admit, it's going to keep me up tonight if I can't come up with a better solution.  And I'm a little rusty, to boot...

The issue is one of data dependency and validation.  The goal is to enforce a restriction on pairs of data values- if the data associated with the node <Fruit><Name> is "Apple", then the value of the sibling node <Fruit><Abbrev> must be "APL".  Effectively, the goal is to enforce a specific mapping from one enum into another within an XML document. The only way my associate could figure to capture this dependency is as follows:

<xs:complexType name="Fruit">
		<xs:documentation>Defines the valid values for fruit types</xs:documentation>
		<xs:element name="APL" type="xs:token" fixed="Apple"/>
		<xs:element name="ORG" type="xs:token" fixed="Orange"/>
		<xs:element name="BAN" type="xs:token" fixed="Banana"/>
		<xs:element name="LEM" type="xs:token" fixed="Lemon"/>
		<xs:element name="GRP" type="xs:token" fixed="Grape"/>

All in all, this strikes me as a very ugly, even offensive, solution.  My initial response was to forget about the validation- it wasn't worth it.  Is there a way to preserve the data dependency validation without warping the instance document as the above schema fragment would require?



News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS