[
Lists Home |
Date Index |
Thread Index
]
From: "Rajan Gupta" <rgupta99_1999@yahoo.com>
> I can write an XMLSchema for Liquids, but how do I enforce that elements
> with water & milk as attribute values are present every time an instance
> document is created of the schema.
You cannot do this AFAIK with W3C XML Schemas or DTDs. You probably
can do it with the Schema languages RELAX NG and Examplotron.
If you use the Schematron assertion language, you can go*
<rule context="FoodItems">
<assert test="Liquid[@name='water']" >Water is an essential food item</assert>
<assert test="Liquid[@name='milk']" >Milk is an essential food item</assert>
</rule>
This captures your rules very simply.
To validate a Schematron schema, you can download implementations
which require an XSLT implementation from http://www.ascc.net/xml/resource/schematron
If you are using a WinTel machine, the simplest thing is to download
the free Topologi Schematron Validator from http://www.topologi.com/
which validates W3C XML Schemas, Schematron, DTD, and Schematron embedded
in XML Schemas.
I believe Eddie Robertsson of Allette Systems is working on a paper giving details
on how to embed a Schematron schema inside XML Schema's <appinfo>
elements.
Cheers
Rick Jelliffe
Topologi Pty. Ltd.
* The full Schematron schema would be something like
<schema xmlns="http://www.ascc.net/xml/schematron">
<title>Guptatron!</title>
<pattern>
<rule context="FoodItems">
<assert test="Liquid[@name='water']">Water is an essential food item</assert>
<assert test="Liquid[@name='milk']" >Milk is an essential food item</assert>
</rule>
</pattern>
</schema>
|