summaryrefslogtreecommitdiff
path: root/doc/lib/dot.count.html
blob: 083b81f05641538f346da8c64c9fb05908e20a6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>dot.count</title><link rel="stylesheet" type="text/css" href="../reference.css"><meta name="generator" content="DocBook XSL Stylesheets V1.76.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="generallibrary.html" title="General Library Templates"><link rel="next" href="copy-string.html" title="copy-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">dot.count</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="generallibrary.html">Prev</a> </td><th width="60%" align="center">General Library Templates</th><td width="20%" align="right"> <a accesskey="n" href="copy-string.html">Next</a></td></tr></table><hr></div><div class="refentry" title="dot.count"><a name="dot.count"></a><div class="titlepage"></div>
<div class="refnamediv"><h2>dot.count</h2><p>
dot.count
 &#8212; Returns the number of <span class="quote">&#8220;<span class="quote">.</span>&#8221;</span> characters in a string
</p></div>

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

  <p>Given a string, the <code class="function">dot.count</code>
    template returns the number of dot/period characters in the
    string. This template is useful, for example, when testing the
    nesting level of nested inline markup (for nested emphasis,
    quotations, etc.).</p>

<a name="dot.count.frag"></a><pre class="programlisting">
&lt;xsl:template name="dot.count"&gt;
  &lt;!-- Returns the number of "." characters in a string --&gt;
  &lt;xsl:param name="string"&gt;&lt;/xsl:param&gt;
  &lt;xsl:param name="count" select="0"&gt;&lt;/xsl:param&gt;
  &lt;xsl:choose&gt;
    &lt;xsl:when test="contains($string, '.')"&gt;
      &lt;xsl:call-template name="dot.count"&gt;
        &lt;xsl:with-param name="string" select="substring-after($string, '.')"&gt;&lt;/xsl:with-param&gt;
        &lt;xsl:with-param name="count" select="$count+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="$count"&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="generallibrary.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="copy-string.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">General Library Templates </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> copy-string</td></tr></table></div></body></html>