|
||||||||
| Chapter 5 - XPath Espresso | |
| XSLT For Dummies | |
| by Richard Wagner | |
| Hungry Minds 2002 | |
XPath, The X-Teams Commando
XPath
is the language used by XSLT to describe how to locate nodes in a source XML document. Think of XPath as the spy or commando who is charged with going into foreign soil, picking out the
Unlike most languages, XPath has a vocabulary that is extremely
Technical Stuff
XPath was originally part of the W3Cs XSLT specification. But after the W3C working
The primary use of XPath is to create location paths, which are instructions that specify what nodes to bring back to the template rule. More precisely, a
location
|
|||||||||||
|
||||||||
| Chapter 5 - XPath Espresso | |
| XSLT For Dummies | |
| by Richard Wagner | |
| Hungry Minds 2002 | |
Dancing the Location Step
People using XSLT have their own
A location step takes the following form: axis::nodetest[predicate] . Figure 5-1 shows the XPath triumvirate.
Tip
In earlier chapters, I have used the
Steppin through a funnel
You can think of a location step as a sifter (see Figure 5-2). For each source tree node
For example, consider the following location step: child::book[@id] When a source tree is processed, for each node, the XSLT processor first uses the child:: axis and returns all the current nodes children as a node set. Next, the processor uses the book node test and returns just the child nodes that are book element nodes. Finally, from this smaller node set, it then uses the @id predicate to filter out all book elements that do not have an id attribute defined.
Steppin up to a location
|
|||||||||||
|
|
||
|
|
|
| 2000-2002 Feedback | |