[moving this over to docbook-apps where such matters are discussed]
The "depth" here is the depth of nesting of emphasis elements. In a
regular emphasis element, the text is italic. If you put an emphasis
inside an emphasis, then that text should be normal within the italic. The
mod 2 alternates them.
The dot.count template is a clever trick to compute the number of
ancestors. The dots it is counting are not in the text, but in a number
generated using xsl:number with level="multiple". This generates a number
like 1.1 for a nested emphasis and 1.1.1 for doubly nested. It counts
those dots to get the depth of nesting to use in the mod expression.
Bob Stayton
Sagehill Enterprises
DocBook Consulting
[EMAIL PROTECTED]
----- Original Message -----
From: "Julie May" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, May 28, 2007 3:56 PM
Subject: [docbook] emphasis role and $depth mod 2 = 1
Hello every one,
Version: docbook-xsl-1.72.0
I hate to customize Docbook code without understanding what possible
errors
code was designed to handle so I am going to ask before removing the
test.
In the template <xsl:template match="emphasis"> I am trying to find out
why
the test <xsl:when test="$depth mod 2 = 1"> exists and what it was
designed
for. Does anyone know? (This same test is used for quote and may be
used
elsewhere.)
I attempted to trigger the test but failed (by adding 2 then 3 periods to
the XML text, since this seems to be testing for an odd number of
periods).
Thanks,
Julie May
Templates in question:
<!--lib/lib.xsl-->
<xsl:template name="dot.count">
<!-- Returns the number of "." characters in a string -->
<xsl:param name="string"/>
<xsl:param name="count" select="0"/>
<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 name="count" select="$count+1"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$count"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!--fo/inline.xsl, also exists in html -->
<xsl:template match="emphasis">
<xsl:variable name="depth">
<xsl:call-template name="dot.count">
<xsl:with-param name="string">
<xsl:number level="multiple"/>
</xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="@role='bold' or @role='strong'">
<xsl:call-template name="inline.boldseq"/>
</xsl:when>
<xsl:when test="@role='underline'">
<fo:inline text-decoration="underline">
<xsl:call-template name="inline.charseq"/>
</fo:inline>
</xsl:when>
<xsl:when test="@role='strikethrough'">
<fo:inline text-decoration="line-through">
<xsl:call-template name="inline.charseq"/>
</fo:inline>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="$depth mod 2 = 1"><!--this is the line referenced
in
the question-->
<fo:inline font-style="normal">
<xsl:apply-templates/>
</fo:inline>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="inline.italicseq"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]