Joshua Mostafa <mi*****@gmail.comwrote in
<11**********************@n59g2000hsh.googlegroups .com>:
I have a question regarding restrictions in an XML Schema
definition.
[...]
The problem is that it should be impossible to specify
more than one favourite. However, I don't know how to
write this rule in XSD. I need to restrict the number of
elements *with a certain attribute value*. Any ideas?
It seems to me that the XML community is coming to the
consensus that W3C's XML Schemata are only to be used for
checking the structural validity of XML documents, and not
for checking the logical validity. (Well, the XML Schema WG
members themselves were probably well-aware of what they
were doing ever since they started working on XML Schema
recommendations.)
I believe Joseph Kesselman recently quoted Dr. Chomsky as a
good example of what that means. I'll do the same:
<quote>
1. Colorless green ideas sleep furiously.
2. Furiously sleep ideas green colorless.
It is fair to assume that neither sentence (1) nor (2) (nor
indeed any part of these sentences) had ever occurred in an
English discourse. Hence, in any statistical model for
grammaticalness, these sentences will be ruled out on
identical grounds as equally "remote" from English. Yet
(1), though nonsensical, is grammatical, while (2) is not.
</quote>
Basically, XML Schemata are for weeding out (2)s, but not
(1)s. As the passage quoted indicates, the boundary between
the two is actually a bit fuzzy, and you may define
grammars that will make certain meanings outright invalid
(Joseph Kesselman's response to your posts contains
examples of those). As a result, if your documents are
highly structured, checking the structural validity will
catch many of the logical inconsistencies. If they're not
(as yours isn't), you'll have to explicitly check for
logical inconsistencies using some other means.
--
Pavel Lepin