]> granicus.if.org Git - docbook-dsssl/commitdiff
Added a toc.line template to handle formatting of each
authorBob Stayton <bobs@sagehill.net>
Mon, 21 Jul 2003 06:30:02 +0000 (06:30 +0000)
committerBob Stayton <bobs@sagehill.net>
Mon, 21 Jul 2003 06:30:02 +0000 (06:30 +0000)
line in a TOC, similar to that in the FO side.
Makes customizing HTML toc easier.

xsl/html/autotoc.xsl

index 446c9372af02422b9969effead7f6a6704aac9f6..1182659daf025f3058ef42db3414511202f7b0e9 100644 (file)
   </xsl:variable>
 
   <xsl:element name="{$toc.listitem.type}">
-    <xsl:variable name="label">
-      <xsl:apply-templates select="." mode="label.markup"/>
-    </xsl:variable>
-    <xsl:copy-of select="$label"/>
-    <xsl:if test="$label != ''">
-      <xsl:value-of select="$autotoc.label.separator"/>
-    </xsl:if>
-
-    <a>
-      <xsl:attribute name="href">
-        <xsl:call-template name="href.target">
-          <xsl:with-param name="context" select="$toc-context"/>
-        </xsl:call-template>
-      </xsl:attribute>
-      <xsl:apply-templates select="." mode="title.markup"/>
-    </a>
+    <xsl:call-template name="toc.line">
+      <xsl:with-param name="toc-context" select="$toc-context"/>
+    </xsl:call-template>
     <xsl:if test="$toc.listitem.type = 'li'
                   and $toc.section.depth > $depth and count($nodes)&gt;0
                   and $toc.max.depth > $depth.from.context">
   </xsl:if>
 </xsl:template>
 
+<xsl:template name="toc.line">
+  <xsl:param name="toc-context" select="."/>
+  <xsl:param name="depth" select="1"/>
+  <xsl:param name="depth.from.context" select="8"/>
+
+ <span>
+  <xsl:attribute name="class"><xsl:value-of select="local-name(.)"/></xsl:attribute>
+  <a>
+    <xsl:attribute name="href">
+      <xsl:call-template name="href.target">
+        <xsl:with-param name="context" select="$toc-context"/>
+      </xsl:call-template>
+    </xsl:attribute>
+    
+    <xsl:variable name="label">
+      <xsl:if test="local-name(.) = 'chapter'
+                 or local-name(.) = 'appendix'
+                 or local-name(.) = 'part'">
+        <xsl:call-template name="gentext">
+          <xsl:with-param name="key" select="local-name(.)"/>
+        </xsl:call-template>
+        <xsl:text> </xsl:text>
+      </xsl:if>
+      <xsl:apply-templates select="." mode="label.markup"/>
+    </xsl:variable>
+    <xsl:copy-of select="$label"/>
+    <xsl:if test="$label != ''">
+      <xsl:value-of select="$autotoc.label.separator"/>
+    </xsl:if>
+
+    <xsl:apply-templates select="." mode="title.markup"/>
+  </a>
+  </span>
+</xsl:template>
+
 <xsl:template match="book|setindex" mode="toc">
   <xsl:param name="toc-context" select="."/>