]> granicus.if.org Git - docbook-dsssl/commitdiff
Support toc.expand.depth to force the top N-levels of the ToC to be expanded
authorNorman Walsh <ndw@nwalsh.com>
Mon, 12 Nov 2001 21:24:17 +0000 (21:24 +0000)
committerNorman Walsh <ndw@nwalsh.com>
Mon, 12 Nov 2001 21:24:17 +0000 (21:24 +0000)
website/xsl/toc-tabular.xsl

index 4c17eecfb00eacd98d6f444e61edc714d7ce0075..777fa08f55e25358896518126f1330d7694f1ef7 100644 (file)
@@ -25,6 +25,8 @@
 
 <xsl:param name="nav.text.pointer">&lt;-</xsl:param>
 
+<xsl:param name="toc.expand.depth" select="1"/>
+
 <!-- ==================================================================== --> 
 
 <xsl:template match="toc/title|tocentry/title|titleabbrev">
@@ -96,6 +98,8 @@
                 select="($page/descendant-or-self::tocentry[@tocskip = '0']
                        |$page/following::tocentry[@tocskip='0'])[1]"/>
 
+  <xsl:variable name="depth" select="count(ancestor::*)-1"/>
+
   <xsl:variable name="isdescendant">
     <xsl:choose>
       <xsl:when test="ancestor::*[@id=$pageid]">1</xsl:when>
     </xsl:choose>
   </xsl:variable>
 
+  <xsl:variable name="isopen">
+    <xsl:choose>
+      <xsl:when test="$pageid = @id
+                      or $isancestor='1'
+                      or $depth &lt; $toc.expand.depth">1</xsl:when>
+      <xsl:otherwise>0</xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
   <!-- For any entry in the TOC:
        1. It is the current page
           a. it is a leaf             current/leaf
       </xsl:when>
       <xsl:otherwise>
         <xsl:choose>
-          <xsl:when test="$isancestor != 0">
-            <xsl:text>/other/open</xsl:text>
+          <xsl:when test="$hasdescendant = 0">
+            <xsl:text>/other/leaf</xsl:text>
           </xsl:when>
-          <xsl:when test="$hasdescendant != 0">
-            <xsl:text>/other/closed</xsl:text>
+          <xsl:when test="$isancestor != 0 or $depth &lt; $toc.expand.depth">
+            <xsl:text>/other/open</xsl:text>
           </xsl:when>
           <xsl:otherwise>
-            <xsl:text>/other/leaf</xsl:text>
+            <xsl:text>/other/closed</xsl:text>
           </xsl:otherwise>
         </xsl:choose>
       </xsl:otherwise>
     </xsl:choose>
   </span>
 
-  <xsl:if test="$pageid = @id or $isancestor='1'">
+  <xsl:if test="$pageid = @id or $isancestor='1' or $depth &lt; $toc.expand.depth">
     <xsl:apply-templates select="tocentry">
       <xsl:with-param name="pageid" select="$pageid"/>
       <xsl:with-param name="relpath" select="$relpath"/>