|
||||||||
| Chapter 5 - XPath Espresso | |
| XSLT For Dummies | |
| by Richard Wagner | |
| Hungry Minds 2002 | |
Take a Walk on the Absolute Side
If you work with directories and files on your computer, youre probably familiar with the concept of relative and absolute paths. For example, suppose I am in the
c:\Windows\System32
directory and want to
..\..\Lattes\espresso.txt Or to use an absolute path, I would use: C:\Lattes\espresso.txt
Like directory/file structures, location paths can either be relative or absolute. A
relative location path
is defined by the axis relation to the current node. Each of the
<xsl:template match="/book/introduction"> <xsl:apply-templates/> </xsl:template> The match pattern starts with / to denote an absolute path and then looks for a book element node just under the root node with an introduction element node as its child. If found, the node set is applied using xsl:apply-templates .
An absolute path is also used when you want to
<xsl:template match="/"> <dummies genre="technology"> <xsl:copy-of select="."/> </dummies> </xsl:template> The match pattern of / selects the root node for the template and adds literal text before and after the result of the xsl:copy-of instruction.
Tip
Notice that some of the XPath syntax looks similar to traditional file system syntax --
.
,
..
,
/
, and
//
? That is more than a
|
|||||||||||
|
||||||||
| Chapter 5 - XPath Espresso | |
| XSLT For Dummies | |
| by Richard Wagner | |
| Hungry Minds 2002 | |
Putting It All TogetherThe following bulleted lists give you a sampling of the various relative and absolute location paths Ive talked about in this chapter.
Axis examples
Node test examples
Predicate examples
Absolute
|
|||||||||||
|
|
||
|
|
|
| 2000-2002 Feedback | |