]> granicus.if.org Git - docbook-dsssl/commitdiff
Fixed bug #1202971, chunktoc doesn't handle the chunk.tocs.and.lots=1
authorBob Stayton <bobs@sagehill.net>
Tue, 31 May 2005 07:46:52 +0000 (07:46 +0000)
committerBob Stayton <bobs@sagehill.net>
Tue, 31 May 2005 07:46:52 +0000 (07:46 +0000)
parameter.

xsl/html/chunktoc.xsl

index d75cd03bc0f155da4712ae1678ac6e08c2f67ab9..502b3a21bc57912a04b5148fc9e7f69d40bc726f 100644 (file)
@@ -28,7 +28,7 @@
     </xsl:call-template>
   </xsl:variable>
 
-  <xsl:variable name="chunks" select="document($chunk.toc,$node)"/>
+  <xsl:variable name="chunks" select="document($chunk.toc,/)"/>
 
   <xsl:choose>
     <xsl:when test="$chunks//tocentry[@linkend=$id]">1</xsl:when>
@@ -45,7 +45,7 @@
     <xsl:call-template name="object.id"/>
   </xsl:variable>
 
-  <xsl:variable name="chunks" select="document($chunk.toc,.)"/>
+  <xsl:variable name="chunks" select="document($chunk.toc,/)"/>
 
   <xsl:variable name="chunk" select="$chunks//tocentry[@linkend=$id]"/>
   <xsl:variable name="filename">
@@ -71,7 +71,7 @@
     <xsl:call-template name="object.id"/>
   </xsl:variable>
 
-  <xsl:variable name="chunks" select="document($chunk.toc,.)"/>
+  <xsl:variable name="chunks" select="document($chunk.toc,/)"/>
 
   <xsl:variable name="chunk" select="$chunks//tocentry[@linkend=$id]"/>
   <xsl:variable name="prev-id"
   <xsl:apply-templates select="."/>
 </xsl:template>
 
+<xsl:template name="make.lots">
+  <xsl:param name="toc.params" select="''"/>
+  <xsl:param name="toc"/>
+
+  <xsl:variable name="lots">
+    <xsl:if test="contains($toc.params, 'toc')">
+      <xsl:copy-of select="$toc"/>
+    </xsl:if>
+
+    <xsl:if test="contains($toc.params, 'figure')">
+      <xsl:choose>
+        <xsl:when test="$chunk.separate.lots != '0'">
+          <xsl:call-template name="make.lot.chunk">
+            <xsl:with-param name="type" select="'figure'"/>
+            <xsl:with-param name="lot">
+              <xsl:call-template name="list.of.titles">
+                <xsl:with-param name="titles" select="'figure'"/>
+                <xsl:with-param name="nodes" select=".//figure"/>
+              </xsl:call-template>
+            </xsl:with-param>
+          </xsl:call-template>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:call-template name="list.of.titles">
+            <xsl:with-param name="titles" select="'figure'"/>
+            <xsl:with-param name="nodes" select=".//figure"/>
+          </xsl:call-template>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:if>
+
+    <xsl:if test="contains($toc.params, 'table')">
+      <xsl:choose>
+        <xsl:when test="$chunk.separate.lots != '0'">
+          <xsl:call-template name="make.lot.chunk">
+            <xsl:with-param name="type" select="'table'"/>
+            <xsl:with-param name="lot">
+              <xsl:call-template name="list.of.titles">
+                <xsl:with-param name="titles" select="'table'"/>
+                <xsl:with-param name="nodes" select=".//table"/>
+              </xsl:call-template>
+            </xsl:with-param>
+          </xsl:call-template>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:call-template name="list.of.titles">
+            <xsl:with-param name="titles" select="'table'"/>
+            <xsl:with-param name="nodes" select=".//table"/>
+          </xsl:call-template>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:if>
+
+    <xsl:if test="contains($toc.params, 'example')">
+      <xsl:choose>
+        <xsl:when test="$chunk.separate.lots != '0'">
+          <xsl:call-template name="make.lot.chunk">
+            <xsl:with-param name="type" select="'example'"/>
+            <xsl:with-param name="lot">
+              <xsl:call-template name="list.of.titles">
+                <xsl:with-param name="titles" select="'example'"/>
+                <xsl:with-param name="nodes" select=".//example"/>
+              </xsl:call-template>
+            </xsl:with-param>
+          </xsl:call-template>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:call-template name="list.of.titles">
+            <xsl:with-param name="titles" select="'example'"/>
+            <xsl:with-param name="nodes" select=".//example"/>
+          </xsl:call-template>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:if>
+
+    <xsl:if test="contains($toc.params, 'equation')">
+      <xsl:choose>
+        <xsl:when test="$chunk.separate.lots != '0'">
+          <xsl:call-template name="make.lot.chunk">
+            <xsl:with-param name="type" select="'equation'"/>
+            <xsl:with-param name="lot">
+              <xsl:call-template name="list.of.titles">
+                <xsl:with-param name="titles" select="'equation'"/>
+                <xsl:with-param name="nodes" select=".//equation"/>
+              </xsl:call-template>
+            </xsl:with-param>
+          </xsl:call-template>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:call-template name="list.of.titles">
+            <xsl:with-param name="titles" select="'equation'"/>
+            <xsl:with-param name="nodes" select=".//equation"/>
+          </xsl:call-template>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:if>
+
+    <xsl:if test="contains($toc.params, 'procedure')">
+      <xsl:choose>
+        <xsl:when test="$chunk.separate.lots != '0'">
+          <xsl:call-template name="make.lot.chunk">
+            <xsl:with-param name="type" select="'procedure'"/>
+            <xsl:with-param name="lot">
+              <xsl:call-template name="list.of.titles">
+                <xsl:with-param name="titles" select="'procedure'"/>
+                <xsl:with-param name="nodes" select=".//procedure[title]"/>
+              </xsl:call-template>
+            </xsl:with-param>
+          </xsl:call-template>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:call-template name="list.of.titles">
+            <xsl:with-param name="titles" select="'procedure'"/>
+            <xsl:with-param name="nodes" select=".//procedure[title]"/>
+          </xsl:call-template>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:if>
+  </xsl:variable>
+
+  <xsl:if test="string($lots) != ''">
+    <xsl:choose>
+      <xsl:when test="$chunk.tocs.and.lots != 0 and not(parent::*)">
+        <xsl:call-template name="write.chunk">
+          <xsl:with-param name="filename">
+            <xsl:call-template name="make-relative-filename">
+              <xsl:with-param name="base.dir" select="$base.dir"/>
+              <xsl:with-param name="base.name">
+                <xsl:call-template name="dbhtml-dir"/>
+                <xsl:apply-templates select="." mode="recursive-chunk-filename">
+                  <xsl:with-param name="recursive" select="true()"/>
+                </xsl:apply-templates>
+                <xsl:text>-toc</xsl:text>
+                <xsl:value-of select="$html.ext"/>
+              </xsl:with-param>
+            </xsl:call-template>
+          </xsl:with-param>
+          <xsl:with-param name="content">
+            <xsl:call-template name="chunk-element-content">
+              <xsl:with-param name="prev" select="/foo"/>
+              <xsl:with-param name="next" select="/foo"/>
+              <xsl:with-param name="nav.context" select="'toc'"/>
+              <xsl:with-param name="content">
+                <h1>
+                  <xsl:apply-templates select="." mode="object.title.markup"/>
+                </h1>
+                <xsl:copy-of select="$lots"/>
+              </xsl:with-param>
+            </xsl:call-template>
+          </xsl:with-param>
+          <xsl:with-param name="quiet" select="$chunk.quietly"/>
+        </xsl:call-template>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:copy-of select="$lots"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template name="make.lot.chunk">
+  <xsl:param name="type" select="''"/>
+  <xsl:param name="lot"/>
+
+  <xsl:if test="string($lot) != ''">
+    <xsl:variable name="filename">
+      <xsl:call-template name="make-relative-filename">
+        <xsl:with-param name="base.dir" select="$base.dir"/>
+        <xsl:with-param name="base.name">
+          <xsl:call-template name="dbhtml-dir"/>
+          <xsl:value-of select="$type"/>
+          <xsl:text>-toc</xsl:text>
+          <xsl:value-of select="$html.ext"/>
+        </xsl:with-param>
+      </xsl:call-template>
+    </xsl:variable>
+
+    <xsl:variable name="href">
+      <xsl:call-template name="make-relative-filename">
+        <xsl:with-param name="base.name">
+          <xsl:call-template name="dbhtml-dir"/>
+          <xsl:value-of select="$type"/>
+          <xsl:text>-toc</xsl:text>
+          <xsl:value-of select="$html.ext"/>
+        </xsl:with-param>
+      </xsl:call-template>
+    </xsl:variable>
+
+    <xsl:call-template name="write.chunk">
+      <xsl:with-param name="filename" select="$filename"/>
+      <xsl:with-param name="content">
+        <xsl:call-template name="chunk-element-content">
+          <xsl:with-param name="prev" select="/foo"/>
+          <xsl:with-param name="next" select="/foo"/>
+          <xsl:with-param name="nav.context" select="'toc'"/>
+          <xsl:with-param name="content">
+            <xsl:copy-of select="$lot"/>
+          </xsl:with-param>
+        </xsl:call-template>
+      </xsl:with-param>
+      <xsl:with-param name="quiet" select="$chunk.quietly"/>
+    </xsl:call-template>
+    <!-- And output a link to this file -->
+    <div>
+      <xsl:attribute name="class">
+        <xsl:text>ListofTitles</xsl:text>
+      </xsl:attribute>
+      <a href="{$href}">
+        <xsl:call-template name="gentext">
+          <xsl:with-param name="key">
+            <xsl:choose>
+              <xsl:when test="$type='table'">ListofTables</xsl:when>
+              <xsl:when test="$type='figure'">ListofFigures</xsl:when>
+              <xsl:when test="$type='equation'">ListofEquations</xsl:when>
+              <xsl:when test="$type='example'">ListofExamples</xsl:when>
+              <xsl:when test="$type='procedure'">ListofProcedures</xsl:when>
+              <xsl:otherwise>ListofUnknown</xsl:otherwise>
+            </xsl:choose>
+          </xsl:with-param>
+        </xsl:call-template>
+      </a>
+    </div>
+  </xsl:if>
+</xsl:template>
+
 </xsl:stylesheet>