|
|
|
|
|
|
| |
XSLT Tutorial
XPath : Axis, Predicate
Axis:
An axis returns a list of nodes, based on the context of the
original node.
The following are examples of some the axis location paths.
| Expression |
Abr. |
Comment |
| self |
. |
This selects the current node in the context.
Example :
<TD><xsl:value-of
select="."/></TD>
If the context node contains a text value, insert this
value.
|
| ancestor |
|
This selects a path
of all parent and parent-of-parent nodes of the current node,
starting from the first parent above the context node.
|
| parent |
.. |
This selects only the single parent of the
context node. |
| attribute |
@ |
This selects all the attributes of an element.
Example:
<TD><xsl:value-of
select="@PERSONID"/></TD>
Selects the PERSONID attribute.
|
| child |
|
Selects all the children of the
current node. This is the default in the abbreviated syntax. |
Predicate
The Axis helps us to find nodes around the current node. To be
able to find a sub-node that contains a specific value, we use a predicate.
It consists of a 'qualifying expression' to do the query.
The syntax for the predicate is:
| [] |
Use square brackets around the expression. |
| Expression |
The expression is inside the brackets. |
|
Example: book[name='Phar Lap'] |
The following are example of Predicates:
| article[position()=2] |
This is syntax to find the second 'article' element. |
| article[starts-with(name,
"B")] |
This is syntax to find all article nodes,
whose name element starts with 'B'. |
|
|
|
|
|
|
|
|
|