"Don Adams" <dg*@sgi.com> wrote in message news:c1*************@fido.engr.sgi.com...
I don't think what I want to do with maxInclusive is possible, but
I thought I'd ask others what they thought.
I agree that it is not possible in XML Schema.
XML Schema defines the structure of an XML instance
document, but it is incapable of validating the content of
structural members against the content of _other_
structural members (you can use enumerations and
regular expression patterns to validate the content of
the structural member currently being validated; that's
about it.)
: : <birthday_cake>
<max_pieces>8</max_pieces>
<serving name="Joe">
<pieces>2</pieces>
</serving>
<serving name="Jane">
<pieces>1</pieces>
</serving>
</birthday_cake>
Is it possible to write a Schema rule to ensure that the maxInclusive
restriction for <pieces> is equal to the value of <max_pieces>?
What you would look for in XML Schema is some manner of
referencing the other members of the document within the
maxInclusive attribute, like allowing XPath expressions.
You won't find this.
One workaround that is sometimes used is to supplement the
validation process of XML Schema with something that does
have intrinsically strong support for XPath expressions: XSLT.
After using XML Schema to validate the structural qualities of
your instance document, its possible to run an XSLT stylesheet
against the instance document that will do inter-element content
validation.
This stylesheet can be as simple as something that returns a
literal text answer to the question of validity: true or false?
It could also be sophisticated enough to return "0 OK" for valid
content, or an error message describing what is invalid, "107
More pieces of cake served (11) than exist pieces of birthday
cake (8)."
Derek Harmon