Lists Home |
Date Index |
I have a situation where I would like to validate the text of an element, based
on the value of an attribute.
A simple example is using units of measure specified in an attribute in the
<myElement uom="meters">2.5</myElement> <myElement
Now assume I want to validate the myElement is always <= 3 meters
(regardless of the unit of measure.....so it's less than roughly 11 feet).
There is no way to do this using just a XMLSchema that I am aware of.
Seems that embedding Schematron assertions in an <appinfo> tag would
probably do the trick (and keeps the validation "logic" embedded in the
XMLSchema document), but is that the best way to handle such validation?
Are there validation solutions "better" than Schematron for such a
If I restructure the above example to look like the following:
Where myElement is defined in a XML Schema using an xsd:choice as
<xsd:element name="feet" type="xsd:decimal"/>
<xsd:element name="meters" type="xsd:decimal"/>
Then you could validate the value range using just a XML Schema (using
restrictions and such).
This seems a less "natural" construct than the use of attributes (since the
attribute uom in this example is really metadata), but does have the benefit of
not requiring external functionality for validation.
Any thoughts on the pros/cons of a nested-elements approach to this
Would definitely appreciate some ideas/opinions/ruminations/best practices on
the "best" way to handle such validations.
Andrzej Jan Taramina
Chaeron Corporation: Enterprise System Solutions