Sophie

Sophie

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

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

<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>lookup.key</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="pi-attribute.html" title="pi-attribute"><link rel="next" href="xpath.location.html" title="xpath.location"><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">lookup.key</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="pi-attribute.html">Prev</a> </td><th width="60%" align="center">General Library Templates</th><td width="20%" align="right"> <a accesskey="n" href="xpath.location.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="lookup.key"></a><div class="titlepage"></div>
<div class="refnamediv"><h2>lookup.key</h2><p>
lookup.key
 &#8212; Retrieve the value associated with a particular key in a table
</p></div>

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

<p>Given a table of space-delimited key/value pairs,
the <code class="function">lookup.key</code> template extracts the value associated
with a particular key.</p>

<a name="lookup.key.frag"></a><pre class="programlisting">
&lt;xsl:template name="lookup.key"&gt;
  &lt;xsl:param name="key" select="''"&gt;&lt;/xsl:param&gt;
  &lt;xsl:param name="table" select="''"&gt;&lt;/xsl:param&gt;

  &lt;xsl:if test="contains($table, ' ')"&gt;
    &lt;xsl:choose&gt;
      &lt;xsl:when test="substring-before($table, ' ') = $key"&gt;
        &lt;xsl:variable name="rest" select="substring-after($table, ' ')"&gt;&lt;/xsl:variable&gt;
        &lt;xsl:choose&gt;
          &lt;xsl:when test="contains($rest, ' ')"&gt;
            &lt;xsl:value-of select="substring-before($rest, ' ')"&gt;&lt;/xsl:value-of&gt;
          &lt;/xsl:when&gt;
          &lt;xsl:otherwise&gt;
            &lt;xsl:value-of select="$rest"&gt;&lt;/xsl:value-of&gt;
          &lt;/xsl:otherwise&gt;
        &lt;/xsl:choose&gt;
      &lt;/xsl:when&gt;
      &lt;xsl:otherwise&gt;
        &lt;xsl:call-template name="lookup.key"&gt;
          &lt;xsl:with-param name="key" select="$key"&gt;&lt;/xsl:with-param&gt;
          &lt;xsl:with-param name="table" select="substring-after(substring-after($table,' '), ' ')"&gt;&lt;/xsl:with-param&gt;
        &lt;/xsl:call-template&gt;
      &lt;/xsl:otherwise&gt;
    &lt;/xsl:choose&gt;
  &lt;/xsl:if&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="pi-attribute.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="xpath.location.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">pi-attribute </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> xpath.location</td></tr></table></div></body></html>