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

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

every $i in //item satisfies @price lt 100)

is incorrect (at any rate, it doesn't do what you probably intended), because the context item doesn't change within this expression, which means that the relative path expression
@price
is not evaluated relative to each item in turn. The way you should write this is:

every $i in //item satisfies $i/@price lt 100)

It's easy to forget that a path expression such as
//item
requires a context node. This expression selects nodes starting from the document node at the root of the tree containing the context node. So when the context item changes, if it selects a node in a different document, then the result of
//item
changes too. This also means (which can come as a surprise) that when the context item isn't a node, an expression such as
//item
gives you an error. For example, this means you can't write:

tokenize(sentence, “\s+”)[not(. = //stopword)]

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

Other books

Babies in Waiting by Rosie fiore
Time's Echo by Pamela Hartshorne
The Ninja's Daughter by Susan Spann
Dead in the Dregs by Peter Lewis
For the Good of the Cause by Alexander Solzhenitsyn
The Lifestyle by Terry Gould
Isle of Night by Veronica Wolff