Generate the minitoc so that it will be formatted like CSS tocs.
authorCameron McCormack <cam@mcc.id.au>
Wed, 09 May 2012 19:18:10 +0200
changeset 8 af7daab6a90d
parent 7 72af89d84c0f
child 9 5dc78496ac46
Generate the minitoc so that it will be formatted like CSS tocs.
publish.xsl
--- a/publish.xsl	Wed May 09 17:28:28 2012 +0200
+++ b/publish.xsl	Wed May 09 19:18:10 2012 +0200
@@ -45,6 +45,7 @@
   <xsl:variable name='publication-date' select='if ($conf/x:publication-date) then xs:date($conf/x:publication-date) else xs:date(current-dateTime())' as='xs:date'/>
 
   <xsl:variable name='this-version' select='if ($maturity = "ED") then $conf/x:versions/x:cvs/@href else $conf/x:versions/x:this/@href'/>
+  <xsl:variable name='this-version-single' select='if ($maturity = "ED") then $conf/x:versions/x:cvs-single/@href else $conf/x:versions/x:this-single/@href'/>
 
   <xsl:variable name='idl-document' select='document($conf/x:interfaces/@idl, $conf-document)'/>
   <xsl:variable name='idl' select='$idl-document/*'/>
@@ -86,6 +87,7 @@
         </xsl:comment>
         <xsl:text>&#10;</xsl:text>
         <xsl:apply-templates select='$d'>
+          <xsl:with-param name='chapter-name' select='"index"' tunnel='yes'/>
           <xsl:with-param name='chapter-number' select='""' tunnel='yes'/>
           <xsl:with-param name='chapter-type' select='"index"' tunnel='yes'/>
           <xsl:with-param name='title-extra' select='$title-extra' tunnel='yes'/>
@@ -126,6 +128,7 @@
         </xsl:comment>
         <xsl:text>&#10;</xsl:text>
         <xsl:apply-templates select='$d'>
+          <xsl:with-param name='chapter-name' select='@name' tunnel='yes'/>
           <xsl:with-param name='chapter-number' select='$chapter-number' tunnel='yes'/>
           <xsl:with-param name='chapter-type' select='$chapter-type' tunnel='yes'/>
           <xsl:with-param name='previous-chapter' select='reverse(preceding-sibling::x:chapter | preceding-sibling::x:appendix | preceding-sibling::x:page)[1]/@name' tunnel='yes'/>
@@ -136,6 +139,7 @@
   </xsl:template>
 
   <xsl:template match='/html'>
+    <xsl:param name='chapter-name' tunnel='yes'/>
     <xsl:param name='chapter-number' tunnel='yes'/>
     <xsl:param name='chapter-type' tunnel='yes'/>
     <xsl:param name='previous-chapter' tunnel='yes'/>
@@ -169,6 +173,13 @@
         <link rel='stylesheet' href='W3C-{$maturity-short}' type='text/css' media='screen'/>
       </head>
       <body>
+        <xsl:attribute name='class'>
+          <xsl:value-of select='@class'/>
+          <xsl:if test='@class != ""'>
+            <xsl:text> </xsl:text>
+          </xsl:if>
+          <xsl:value-of select='concat("chapter-", $chapter-name)'/>
+        </xsl:attribute>
         <xsl:variable name='header'>
           <xsl:call-template name='header'>
             <xsl:with-param name='previous-chapter' select='$previous-chapter'/>
@@ -263,23 +274,23 @@
     <xsl:if test='$conf/x:page'>
       <ul class='toc'>
         <xsl:for-each select='$conf/x:page'>
-          <li class='tocline1'><a href='{@name}.html'><xsl:value-of select='document(concat(@name, ".html"), .)/html/body/h1'/></a></li>
+          <li class="no-num"><a href='{@name}.html'><xsl:value-of select='document(concat(@name, ".html"), .)/html/body/h1'/></a></li>
         </xsl:for-each>
       </ul>
     </xsl:if>
     <xsl:if test='$conf/x:chapter'>
-      <ol class='toc'>
+      <ul class='toc'>
         <xsl:for-each select='$conf/x:chapter'>
-          <li class='tocline1'><a href='{@name}.html'><xsl:value-of select='position()'/><xsl:text> </xsl:text><xsl:value-of select='document(concat(@name, ".html"), .)/html/body/h1'/></a></li>
+          <li><a href='{@name}.html'><span class="secno"><xsl:value-of select='position()'/>.</span><xsl:text> </xsl:text><xsl:value-of select='document(concat(@name, ".html"), .)/html/body/h1'/></a></li>
         </xsl:for-each>
-      </ol>
+      </ul>
     </xsl:if>
     <xsl:if test='$conf/x:appendix'>
-      <ol class='toc'>
+      <ul class='toc'>
         <xsl:for-each select='$conf/x:appendix'>
-          <li class='tocline1'><a href='{@name}.html'>Appendix <xsl:number value='position()' format='A'/>: <xsl:value-of select='document(concat(@name, ".html"), .)/html/body/h1'/></a></li>
+          <li class="no-num"><a href='{@name}.html'>Appendix <xsl:number value='position()' format='A'/>: <xsl:value-of select='document(concat(@name, ".html"), .)/html/body/h1'/></a></li>
         </xsl:for-each>
-      </ol>
+      </ul>
     </xsl:if>
   </xsl:template>
 
@@ -1251,7 +1262,17 @@
   </xsl:template>
 
   <xsl:template match='edit:thisversion'>
-    <a href='{$this-version}' class='url'><xsl:value-of select='$this-version'/></a>
+    <xsl:variable name='url'>
+      <xsl:choose>
+        <xsl:when test='@single-page != ""'>
+          <xsl:value-of select='$this-version-single'/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:value-of select='$this-version'/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+    <a href='{$url}' class='url'><xsl:value-of select='$url'/></a>
   </xsl:template>
 
   <xsl:template match='edit:latestversion'>
@@ -1259,6 +1280,14 @@
     <a href='{$href}' class='url'><xsl:value-of select='$href'/></a>
   </xsl:template>
 
+  <xsl:template match='edit:includelatesteditorsdraft'>
+    <xsl:if test='$maturity != "ED"'>
+      <xsl:variable name='href' select='$conf/x:versions/x:cvs/@href'/>
+      <dt>Latest editor's draft:</dt>
+      <dd><a href='{$href}' class='url'><xsl:value-of select='$href'/></a></dd>
+    </xsl:if>
+  </xsl:template>
+
   <xsl:template match='edit:previousversion'>
     <xsl:variable name='href' select='$conf/x:versions/x:previous/@href'/>
     <a href='{$href}' class='url'><xsl:value-of select='$href'/></a>