Sophie

Sophie

distrib > Mageia > 7 > i586 > media > core-release > by-pkgid > 6e019a662639ac6470f50dea3a4d8157 > files > 932

docbook-style-xsl-doc-1.79.2-4.mga7.noarch.rpm

<html><head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   <title>apply-string-subst-map</title><link rel="stylesheet" type="text/css" href="../reference.css"><meta name="generator" content="DocBook XSL Stylesheets V1.79.2"><link rel="home" href="../index.html" title="DocBook XSL Stylesheets: Reference&nbsp;Documentation"><link rel="up" href="generallibrary.html" title="General Library Templates"><link rel="prev" href="str.tokenize.keep.delimiters.html" title="str.tokenize.keep.delimiters"><link rel="next" href="relativeuri.html" title="Relative URI Functions"><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">apply-string-subst-map</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="str.tokenize.keep.delimiters.html">Prev</a>&nbsp;</td><th width="60%" align="center">General Library Templates</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="relativeuri.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="apply-string-subst-map"></a><div class="titlepage"></div><div class="refnamediv"><h2>apply-string-subst-map</h2><p>apply-string-subst-map &#8212; Apply a string-substitution map</p></div><div class="refsect1"><a name="d0e33519"></a><h2>Description</h2><p>This function applies a &#8220;string substitution&#8221; map. Use it when
  you want to do multiple string substitutions on the same target
  content. It reads in two things: <em class="parameter"><code>content</code></em>, the
  content on which to perform the substitution, and
  <em class="parameter"><code>map.contents</code></em>, a node set of
  elements (the names of the elements don't matter), with each element
  having the following attributes:
  </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><code class="sgmltag-attribute">oldstring</code>, a string to
      be replaced</li><li class="listitem"><code class="sgmltag-attribute">newstring</code>, a string with
      which to replace <code class="sgmltag-attribute">oldstring</code></li></ul></div><p>
  The function uses <em class="parameter"><code>map.contents</code></em> to
  do substitution on <em class="parameter"><code>content</code></em>, and then
  returns the modified contents.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This function is a very slightly modified version of Jeni
    Tennison&#8217;s <code class="function">replace_strings</code> function in the
    <a class="link" href="http://www.dpawson.co.uk/xsl/sect2/StringReplace.html#d9351e13" target="_top">multiple string replacements</a> section of Dave Pawson&#8217;s
    <a class="link" href="http://www.dpawson.co.uk/xsl/index.html" target="_top">XSLT
    FAQ</a>.</p><p>The <code class="function">apply-string-subst-map</code> function is
    essentially the same function as the
    <code class="function">apply-character-map</code> function; the only
    difference is that in the map that
    <code class="function">apply-string-subst-map</code> expects, <code class="sgmltag-attribute">oldstring</code> and <code class="sgmltag-attribute">newstring</code> attributes are used instead of
    <code class="sgmltag-attribute">character</code> and <code class="sgmltag-attribute">string</code> attributes.</p></div><a name="apply-string-subst-map.frag"></a><pre class="programlisting">
    &lt;xsl:template name="apply-string-subst-map"&gt;
      &lt;xsl:param name="content"&gt;&lt;/xsl:param&gt;
      &lt;xsl:param name="map.contents"&gt;&lt;/xsl:param&gt;
      &lt;xsl:variable name="replaced_text"&gt;
        &lt;xsl:call-template name="string.subst"&gt;
          &lt;xsl:with-param name="string" select="$content"&gt;&lt;/xsl:with-param&gt;
          &lt;xsl:with-param name="target" select="$map.contents[1]/@oldstring"&gt;&lt;/xsl:with-param&gt;
          &lt;xsl:with-param name="replacement" select="$map.contents[1]/@newstring"&gt;&lt;/xsl:with-param&gt;
        &lt;/xsl:call-template&gt;
      &lt;/xsl:variable&gt;
      &lt;xsl:choose&gt;
        &lt;xsl:when test="$map.contents[2]"&gt;
          &lt;xsl:call-template name="apply-string-subst-map"&gt;
            &lt;xsl:with-param name="content" select="$replaced_text"&gt;&lt;/xsl:with-param&gt;
            &lt;xsl:with-param name="map.contents" select="$map.contents[position() &gt; 1]"&gt;&lt;/xsl:with-param&gt;
          &lt;/xsl:call-template&gt;
        &lt;/xsl:when&gt;
        &lt;xsl:otherwise&gt;
          &lt;xsl:value-of select="$replaced_text"&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="str.tokenize.keep.delimiters.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="generallibrary.html">Up</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="relativeuri.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">str.tokenize.keep.delimiters&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;Relative URI Functions</td></tr></table></div></body></html>