XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition (293 page)

BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition
12.28Mb size Format: txt, pdf, ePub

The productions
QName
and
NCName
are actually defined in the XML Namespaces Recommendation, not in XPath itself. This ensures that any name that can be used for an element or attribute in a source document can also be used in an XPath expression. These are lexical rules, rather than syntax rules, which means that no whitespace is allowed between the symbols.

Informally, an
NCName
starts with a letter or underscore, and continues with zero or more
NCNameChars
, which may be letters, digits, or the three punctuation characters dot, hyphen, and underscore. The
Letter
and
Digit
categories include a wide variety of characters and ideographs in non-Latin scripts as well as accented Latin letters, while the
CombiningChar
and
Extender
categories cover accents and diacritics in many different languages.

The rules for
Letter
,
Digit
,
CombiningChar
, and
Extender
are given in the XML specification. The definitions are in the form of long lists of Unicode characters, and little would be gained by repeating them here. The basic principle is that if a name is valid in XML, then it is also valid in XPath.

In nearly all contexts, the kind of name that is allowed in XPath is a
QName
. This means a lexical
QName
as defined in the XML Namespaces Recommendation, which either takes the form
prefix:local-name
, where both the prefix and the local-name are
NCNames
(no-colon names), or the simpler form
local-name
in which the prefix is omitted. If a prefix is present, then it must always be one that has been declared in the static namespace context for the XPath expression, as described later in this chapter. If no prefix is present, then the interpretation depends on what kind of name it is. If it is used where an element name is expected, then it is taken to refer to the default namespace for elements, which is also defined in the static context of the expression. If it is used where an attribute name is expected, then the local-name is assumed to be a name that is not in any namespace.

As in XML, names are case-sensitive, and names are only considered to match when they consist of exactly the same sequence of characters (or more strictly, the same Unicode code-points). This is true even when the Unicode standards describe characters as equivalent; for example, different ways of writing accented letters.

Other books

Razor Wire Pubic Hair by Carlton Mellick III
Un fuego en el sol by George Alec Effinger
Kill and Tell by Linda Howard
The Meridian Gamble by Garcia, Daniel
The Secret Agent by Stephan Talty
Half World by Hiromi Goto