Sophie

Sophie

distrib > Fedora > 17 > i386 > media > updates > by-pkgid > 9f452694b2d23dacae7f9cc757f9be50 > files > 942

docbook-style-xsl-1.78.1-1.fc17.noarch.rpm

<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>xpath.location</title><link rel="stylesheet" type="text/css" href="../reference.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="../index.html" title="DocBook XSL Stylesheets: Reference Documentation"><link rel="up" href="generallibrary.html" title="General Library Templates"><link rel="prev" href="lookup.key.html" title="lookup.key"><link rel="next" href="comment-escape-string.html" title="comment-escape-string"><link rel="copyright" href="copyright.html" title="License"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">xpath.location</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="lookup.key.html">Prev</a> </td><th width="60%" align="center">General Library Templates</th><td width="20%" align="right"> <a accesskey="n" href="comment-escape-string.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="xpath.location"></a><div class="titlepage"></div>
<div class="refnamediv"><h2>xpath.location</h2><p>
xpath.location
 &#8212; Calculate the XPath child-sequence to the current node
</p></div>

<div class="refsect1"><a name="idp9563168"></a><h2>Description</h2>

<p>The <code class="function">xpath.location</code> template calculates the
absolute path from the root of the tree to the current element node.
</p>

<a name="xpath.location.frag"></a><pre class="programlisting">
&lt;xsl:template name="xpath.location"&gt;
  &lt;xsl:param name="node" select="."&gt;&lt;/xsl:param&gt;
  &lt;xsl:param name="path" select="''"&gt;&lt;/xsl:param&gt;

  &lt;xsl:variable name="next.path"&gt;
    &lt;xsl:value-of select="local-name($node)"&gt;&lt;/xsl:value-of&gt;
    &lt;xsl:if test="$path != ''"&gt;/&lt;/xsl:if&gt;
    &lt;xsl:value-of select="$path"&gt;&lt;/xsl:value-of&gt;
  &lt;/xsl:variable&gt;

  &lt;xsl:choose&gt;
    &lt;xsl:when test="$node/parent::*"&gt;
      &lt;xsl:call-template name="xpath.location"&gt;
        &lt;xsl:with-param name="node" select="$node/parent::*"&gt;&lt;/xsl:with-param&gt;
        &lt;xsl:with-param name="path" select="$next.path"&gt;&lt;/xsl:with-param&gt;
      &lt;/xsl:call-template&gt;
    &lt;/xsl:when&gt;
    &lt;xsl:otherwise&gt;
      &lt;xsl:text&gt;/&lt;/xsl:text&gt;
      &lt;xsl:value-of select="$next.path"&gt;&lt;/xsl:value-of&gt;
    &lt;/xsl:otherwise&gt;
  &lt;/xsl:choose&gt;
&lt;/xsl:template&gt;
</pre>

</div>
</div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="lookup.key.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="generallibrary.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="comment-escape-string.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">lookup.key </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> comment-escape-string</td></tr></table></div></body></html>