dot.count — Returns the number of “.” characters in a string
Given a string, the dot.count
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.).
<xsl:template name="dot.count"> <!-- Returns the number of "." characters in a string --> <xsl:param name="string"></xsl:param> <xsl:param name="count" select="0"></xsl:param> <xsl:choose> <xsl:when test="contains($string, '.')"> <xsl:call-template name="dot.count"> <xsl:with-param name="string" select="substring-after($string, '.')"></xsl:with-param> <xsl:with-param name="count" select="$count+1"></xsl:with-param> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$count"></xsl:value-of> </xsl:otherwise> </xsl:choose> </xsl:template>