XML Tutorial/XPath/context — различия между версиями

Материал из Web эксперт
Перейти к: навигация, поиск
 
м (1 версия)
 
(нет различий)

Текущая версия на 08:26, 26 мая 2010

Understanding Context

In XPath, the context indicates the location of the node where a processor is currently situated. 
That node is called the context node. 
The context also includes a context position and a context size. 
Consider the following XML document, book.xml: 
<Book>
    <Chapter number="1">This is the first chapter</Chapter>
    <Chapter number="2">This is the second chapter</Chapter>
    <Chapter number="3">This is the third chapter</Chapter>
    <Chapter number="4">This is the fourth chapter</Chapter>
    <Chapter number="5">This is the fifth chapter</Chapter>
</Book> 
Suppose the context node is the node that represents the Chapter element node for the second chapter. 
We can use the position() and last() functions to show the position of the context node and the context size.