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
13.53Mb 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

Under a Raging Moon by Zafiro, Frank
Fifty Shades of Mr Darcy: A Parody by William Codpiece Thwackery
Forbidden Angel by Rice, Sandra Lea
Social Skills by Alva, Sara
United States Of Apocalypse by Mark Tufo, Armand Rosamilia
Platform by Michel Houellebecq