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

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

  • . As far as XPath is concerned, an XPath expression can contain a tab character inside a string literal (and indeed, that's what it sees in this example), but to get the tab character past the XML parser, you need to escape it.
  • Similarly, when XPath expressions are written within character strings in a host language such as Java, you will need to use the escaping conventions of that language: for example, a backslash needs to be written as
    \\
    and a quotation mark as
    \”
    .

XPath is an unusual language in that it has no reserved words. Unembellished names in an XPath expression, such as
table
and
author
, refer to elements or attributes in the source document that have these names. Since there are no restrictions on what you can call the elements in your source document (other than the characters that can be used), XPath has been designed so there are no restrictions on the names that can appear in the XPath expression. The result is that other names (for example, the names of variables and functions, as well as language keywords) have to be either embellished in some way, or recognized by the context in which they appear. There are several ways the grammar achieves this:

  • Names of variables are always preceded by a
    $
    sign, for example
    $x
    (whitespace is allowed between the
    $
    and the
    x
    , though it is rarely used in practice).
  • Names of functions are always followed by a left parenthesis; for example,
    not(
    . Again, whitespace is allowed before the
    (
    . Some syntactic keywords use the same convention. For example,
    if
    in a conditional expression is always followed by
    (
    , and node tests such as
    element()
    are also written with parentheses. (This node test matches any element node; if you leave out the parentheses, then it matches only elements that have the name
    element
    .)

Other books

Water Lessons by Chadwick Wall
Fight Song by Joshua Mohr
Lucinda's Secret by Tony DiTerlizzi, Holly Black
"All You Zombies-" by Robert A. Heinlein
Rabbit Redux by John Updike
Waiting For You by Higgins, Marie