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

BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition
12.3Mb size Format: txt, pdf, ePub
  • , the first node in
    $S
    would be dropped only if every
    A
    has exactly one
    B
    child.
  • Finally,
    /
    is not associative when one step selects nodes and another selects atomic values. For example,
    (A/..)/name()
    selects one node (the parent of all the A children, that is, the node you started from) and then selects its name. However,
    A/(../name())
    repeats the name of the parent node as many times as there are
    A
    nodes.

These examples are fairly pathological, but you might like to try them out on your chosen XPath processor to see how well it handles them. There may well be much simpler path expressions in which
/
is not associative, but I haven't discovered them yet!

Axis Steps

This section discusses the expressions called axis steps. Axis steps are often used as operands of the
/
operator in a path expression, which is how they got their name (a path consists of many steps). But an axis step is an expression in its own right, and it can be used on its own without any need for a
/
operator. We've also seen that XPath 2.0 allows the operands of
/
to be any kind of expression, they are no longer constrained to be axis steps. So the
/
operator and axis steps have become quite decoupled in the semantics of the language. However, they are so often used together that it makes sense to retain the term
path expression
to describe any expression that uses either a
/
operator or an axis step or both.

Other books

American Dirt : A Novel (2020) by Cummins, Jeanine
The Naked Detective by Vivi Andrews
Hell's Pawn by Jay Bell
Soar by Tracy Edward Wymer
Croc's Return by Eve Langlais
Valour by John Gwynne