<xsl:otherwise>1</xsl:otherwise>
</xsl:choose>
</xsl:when>
- <xsl:when test="name($node)='refsect1'">1</xsl:when>
- <xsl:when test="name($node)='refsect2'">2</xsl:when>
- <xsl:when test="name($node)='refsect3'">3</xsl:when>
- <xsl:when test="name($node)='refsection'">
- <xsl:choose>
- <xsl:when test="$node/../../../../../refsection">5</xsl:when>
- <xsl:when test="$node/../../../../refsection">4</xsl:when>
- <xsl:when test="$node/../../../refsection">3</xsl:when>
- <xsl:when test="$node/../../refsection">2</xsl:when>
- <xsl:otherwise>1</xsl:otherwise>
- </xsl:choose>
+ <xsl:when test="name($node)='refsect1' or
+ name($node)='refsect2' or
+ name($node)='refsect3' or
+ name($node)='refsection' or
+ name($node)='refsynopsisdiv'">
+ <xsl:call-template name="refentry.section.level">
+ <xsl:with-param name="node" select="$node"/>
+ </xsl:call-template>
</xsl:when>
<xsl:when test="name($node)='simplesect'">
<xsl:choose>
</xsl:choose>
</xsl:template>
+<!-- Finds the total section depth of a section in a refentry -->
+<xsl:template name="refentry.section.level">
+ <xsl:param name="node" select="."/>
+
+ <xsl:variable name="RElevel">
+ <xsl:call-template name="refentry.level">
+ <xsl:with-param name="node" select="$node/ancestor::refentry[1]"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="levelinRE">
+ <xsl:choose>
+ <xsl:when test="name($node)='refsynopsisdiv'">1</xsl:when>
+ <xsl:when test="name($node)='refsect1'">1</xsl:when>
+ <xsl:when test="name($node)='refsect2'">2</xsl:when>
+ <xsl:when test="name($node)='refsect3'">3</xsl:when>
+ <xsl:when test="name($node)='refsection'">
+ <xsl:choose>
+ <xsl:when test="$node/../../../../../refsection">5</xsl:when>
+ <xsl:when test="$node/../../../../refsection">4</xsl:when>
+ <xsl:when test="$node/../../../refsection">3</xsl:when>
+ <xsl:when test="$node/../../refsection">2</xsl:when>
+ <xsl:otherwise>1</xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:value-of select="$levelinRE + $RElevel"/>
+</xsl:template>
+
+<!-- Finds the section depth of a refentry -->
+<xsl:template name="refentry.level">
+ <xsl:param name="node" select="."/>
+ <xsl:variable name="container"
+ select="($node/ancestor::section |
+ $node/ancestor::sect1 |
+ $node/ancestor::sect2 |
+ $node/ancestor::sect3 |
+ $node/ancestor::sect4 |
+ $node/ancestor::sect5)[last()]"/>
+
+ <xsl:choose>
+ <xsl:when test="$container">
+ <xsl:variable name="slevel">
+ <xsl:call-template name="section.level">
+ <xsl:with-param name="node" select="$container"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:value-of select="$slevel + 1"/>
+ </xsl:when>
+ <xsl:otherwise>1</xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
<xsl:template name="qandadiv.section.level">
<xsl:variable name="section.level">
<xsl:call-template name="qanda.section.level"/>
<xsl:text>0</xsl:text>
</xsl:when>
<xsl:when test="name($object)='textobject'
- and $object/ancestor::equation ">
- <!-- The first textobject is not a reasonable fallback
- for equation image -->
+ and $object/ancestor::equation ">
+ <!-- The first textobject is not a reasonable fallback
+ for equation image -->
<xsl:text>0</xsl:text>
- </xsl:when>
+ </xsl:when>
<!-- The first textobject is a reasonable fallback -->
<xsl:when test="name($object)='textobject'
- and $object[not(@role) or @role!='tex']">
+ and $object[not(@role) or @role!='tex']">
<xsl:text>1</xsl:text>
</xsl:when>
<!-- don't use graphic when output is FO, TeX Math is used