Why are XPath operators case sensitive?
I'm sure there is a reason for this, but: Why are XPath operators case sens开发者_如何转开发itive?
This is not about solving an XPath problem (we're already working around that) - I'd just like to know why I have to bother!
I think most modern languages are case-sensitive. Clearly it made sense for XPath to follow XML. One reason for XML to be case-sensitive is that case-folding can be quite a complex business when you extend beyond the English alphabet: for example the upper-case of ß is SS but the lower-case of SS is ss. So are Straße and Strasse the same element name?
XPath is case-sensitive because XML is case-sensitive.
Therefore,
/AAA
is not the same as:
/aaa
As for the operators, in XPath 1.0 most operators are composed entirely of non-alphabet characters.
Finally, the or
, and
and div
operators and the Xpath 2.0 operators that are composed of letters -- such as union
, intersect
, except
. The reason here for the case sensitivity of these is the same as for the majority of modern programming languages (excluding VB and SQL).
Well XML is case-sensitive (i.e. 'foo', 'FOO', 'Foo' are all different names in XML), that way any language meant to select nodes in an XML document needs to distinguish the case, at least for those parts of the language dealing with node selection by name.
If you are really asking about operators like the for instance the logical operators and
and or
then I think it is just consistency with XML being case-sensitive and that way some parts of XPath being necessarily case-sensitive. But that's my guess, I don't know details about the design process of XPath. http://www.w3.org/TR/xpath/ lists email addresses of the editors and there might even be public archives of the W3C email lists documenting the design process you could search through.
精彩评论