]> granicus.if.org Git - docbook-dsssl/commitdiff
Make index elements always index the book that contains them (if there is one, otherw...
authorNorman Walsh <ndw@nwalsh.com>
Wed, 1 Jan 2003 20:33:19 +0000 (20:33 +0000)
committerNorman Walsh <ndw@nwalsh.com>
Wed, 1 Jan 2003 20:33:19 +0000 (20:33 +0000)
xsl/fo/autoidx.xsl
xsl/fo/index.xsl
xsl/html/autoidx.xsl
xsl/html/index.xsl

index 78c23c3432aae57a2ee8c34ec94329bc2d8fb5a3..ec0a028add2fba6162cc9b289459c8a23f1dae69 100644 (file)
          use="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, see)"/>
 
 <xsl:template name="generate-index">
+  <xsl:param name="root" select="/"/>
+
   <xsl:variable name="scope" select=".." />
   <xsl:variable name="terms"
-                select="..//indexterm[count(.|key('letter',
+                select="$root//indexterm[count(.|key('letter',
                                                 translate(substring(&primary;, 1, 1),
                                                           &lowercase;,
                                                           &uppercase;))[ancestor::* = $scope][1]) = 1
 <!-- ====================================================================== -->
 
 <xsl:template name="generate-index-markup">
+  <xsl:param name="root" select="/"/>
+
   <xsl:variable name="scope" select=".."/>
-  <xsl:variable name="terms" select="..//indexterm[count(.|key('letter',
+  <xsl:variable name="terms" select="$root//indexterm[count(.|key('letter',
                                      translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;))[ancestor::* = $scope][1]) = 1]"/>
   <xsl:variable name="alphabetical"
                 select="$terms[contains(concat(&lowercase;, &uppercase;),
index 2f1169d4c309b1e08daf8a084afc4b8a66140faa..acddfceda1a5c7a9472ae54b321866eef6c02e59 100644 (file)
@@ -24,7 +24,9 @@
   <xsl:choose>
     <xsl:when test="$make.index.markup != 0">
       <fo:block>
-        <xsl:call-template name="generate-index-markup"/>
+        <xsl:call-template name="generate-index-markup">
+          <xsl:with-param name="root" select="(ancestor::book|/)[last()]"/>
+        </xsl:call-template>
       </fo:block>
     </xsl:when>
     <xsl:otherwise>
@@ -33,7 +35,9 @@
         <xsl:call-template name="index.titlepage"/>
         <xsl:apply-templates/>
         <xsl:if test="count(indexentry) = 0 and count(indexdiv) = 0">
-          <xsl:call-template name="generate-index"/>
+          <xsl:call-template name="generate-index">
+            <xsl:with-param name="root" select="(ancestor::book|/)[last()]"/>
+          </xsl:call-template>
         </xsl:if>
       </fo:block>
     </xsl:otherwise>
                       white-space-collapse='false'
                       xsl:use-attribute-sets="monospace.verbatim.properties"
                       linefeed-treatment="preserve">
-              <xsl:call-template name="generate-index-markup"/>
+              <xsl:call-template name="generate-index-markup">
+                <xsl:with-param name="root" select="(ancestor::book|/)[last()]"/>
+              </xsl:call-template>
             </fo:block>
           </xsl:when>
           <xsl:when test="indexentry|indexdiv/indexentry">
             <xsl:apply-templates/>
           </xsl:when>
           <xsl:otherwise>
-            <xsl:call-template name="generate-index"/>
+            <xsl:call-template name="generate-index">
+              <xsl:with-param name="root" select="(ancestor::book|/)[last()]"/>
+            </xsl:call-template>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:if>
+    </fo:flow>
+  </fo:page-sequence>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match="setindex">
+  <xsl:variable name="id">
+    <xsl:call-template name="object.id"/>
+  </xsl:variable>
+
+ <xsl:if test="$generate.index != 0">
+  <xsl:variable name="master-reference">
+    <xsl:call-template name="select.pagemaster">
+      <xsl:with-param name="pageclass">
+        <xsl:if test="$make.index.markup != 0">body</xsl:if>
+      </xsl:with-param>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <fo:page-sequence id="{$id}"
+                    hyphenate="{$hyphenate}"
+                    master-reference="{$master-reference}">
+    <xsl:attribute name="language">
+      <xsl:call-template name="l10n.language"/>
+    </xsl:attribute>
+    <xsl:attribute name="format">
+      <xsl:call-template name="page.number.format"/>
+    </xsl:attribute>
+    <xsl:if test="$double.sided != 0">
+      <xsl:attribute name="initial-page-number">auto-odd</xsl:attribute>
+    </xsl:if>
+
+    <xsl:apply-templates select="." mode="running.head.mode">
+      <xsl:with-param name="master-reference" select="$master-reference"/>
+    </xsl:apply-templates>
+    <xsl:apply-templates select="." mode="running.foot.mode">
+      <xsl:with-param name="master-reference" select="$master-reference"/>
+    </xsl:apply-templates>
+
+    <fo:flow flow-name="xsl-region-body">
+      <xsl:call-template name="index.titlepage"/>
+      <xsl:apply-templates/>
+      <xsl:if test="count(indexentry) = 0 and count(indexdiv) = 0">
+
+        <xsl:choose>
+          <xsl:when test="$make.index.markup != 0">
+            <fo:block wrap-option='no-wrap'
+                      white-space-collapse='false'
+                      xsl:use-attribute-sets="monospace.verbatim.properties"
+                      linefeed-treatment="preserve">
+              <xsl:call-template name="generate-index-markup">
+                <xsl:with-param name="root" select="/"/>
+              </xsl:call-template>
+            </fo:block>
+          </xsl:when>
+          <xsl:when test="indexentry|indexdiv/indexentry">
+            <xsl:apply-templates/>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:call-template name="generate-index">
+              <xsl:with-param name="root" select="/"/>
+            </xsl:call-template>
           </xsl:otherwise>
         </xsl:choose>
       </xsl:if>
index aacaac1e843fc40c17af4eb9884924f3a4c88807..4f9f65b218381df4545d7b98b1568cf24be67fd2 100644 (file)
 <xsl:key name="sections" match="*[@id]" use="@id"/>
 
 <xsl:template name="generate-index">
+  <xsl:param name="root" select="/"/>
+
   <xsl:variable name="terms"
-                select="//indexterm[count(.|key('letter',
+                select="$root//indexterm[count(.|key('letter',
                                                 translate(substring(&primary;, 1, 1),
                                                           &lowercase;,
                                                           &uppercase;))[1]) = 1
index 6f8264ce275824d2a07974d68711d2442af99ef0..3b1e0b65869778626503b0d60e16e3bcd45e97bd 100644 (file)
@@ -14,7 +14,7 @@
 
 <!-- ==================================================================== -->
 
-<xsl:template match="index|setindex">
+<xsl:template match="index">
   <!-- some implementations use completely empty index tags to indicate -->
   <!-- where an automatically generated index should be inserted. so -->
   <!-- if the index is completely empty, skip it. Unless generate.index -->
       <xsl:apply-templates/>
 
       <xsl:if test="count(indexentry) = 0 and count(indexdiv) = 0">
-        <xsl:call-template name="generate-index"/>
+        <xsl:call-template name="generate-index">
+          <xsl:with-param name="root" select="(ancestor::book|/)[last()]"/>
+        </xsl:call-template>
+      </xsl:if>
+
+      <xsl:if test="not(parent::article)">
+        <xsl:call-template name="process.footnotes"/>
+      </xsl:if>
+    </div>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match="setindex">
+  <!-- some implementations use completely empty index tags to indicate -->
+  <!-- where an automatically generated index should be inserted. so -->
+  <!-- if the index is completely empty, skip it. Unless generate.index -->
+  <!-- is non-zero, in which case, this is where the automatically -->
+  <!-- generated index should go. -->
+
+  <xsl:if test="count(*)>0 or $generate.index != '0'">
+    <div class="{name(.)}">
+      <xsl:if test="$generate.id.attributes != 0">
+        <xsl:attribute name="id">
+          <xsl:call-template name="object.id"/>
+        </xsl:attribute>
+      </xsl:if>
+
+      <xsl:call-template name="index.titlepage"/>
+      <xsl:apply-templates/>
+
+      <xsl:if test="count(indexentry) = 0 and count(indexdiv) = 0">
+        <xsl:call-template name="generate-index">
+          <xsl:with-param name="root" select="/"/>
+        </xsl:call-template>
       </xsl:if>
 
       <xsl:if test="not(parent::article)">