]> granicus.if.org Git - docbook-dsssl/commitdiff
Added support for XEP index extensions. If you set xep.extensions to 1 duplicate...
authorJirka Kosek <jirka@kosek.cz>
Wed, 14 May 2003 12:34:43 +0000 (12:34 +0000)
committerJirka Kosek <jirka@kosek.cz>
Wed, 14 May 2003 12:34:43 +0000 (12:34 +0000)
xsl/fo/autoidx.xsl
xsl/fo/index.xsl
xsl/fo/param.ent
xsl/fo/param.xweb
xsl/params/xep.index.item.properties.xml [new file with mode: 0644]

index 371fd8b4ef29980ffcac327ee7cc1bfc0320a8b5..d7f499de55aefb504a6c6878fe481923b6d8edcc 100644 (file)
@@ -13,6 +13,7 @@
 ]>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 xmlns:fo="http://www.w3.org/1999/XSL/Format"
+                xmlns:rx="http://www.renderx.com/XSL/Extensions"
                 version="1.0">
 
 <!-- ********************************************************************
   <fo:block>
     <xsl:value-of select="primary"/>
 
-    <xsl:variable name="page-number-citations">
-      <xsl:for-each select="$refs[not(see) and not(seealso)
-                            and not(secondary)]">
-        <xsl:apply-templates select="." mode="reference">
-          <xsl:with-param name="scope" select="$scope"/>
-        </xsl:apply-templates>
-      </xsl:for-each>
-
-      <xsl:if test="$refs[not(secondary)]/*[self::see]">
-        <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &sep;, &sep;, see))[&scope;][1])]"
-                             mode="index-see">
-           <xsl:with-param name="scope" select="$scope"/>
-           <xsl:sort select="translate(see, &lowercase;, &uppercase;)"/>
-        </xsl:apply-templates>
-      </xsl:if>
-    </xsl:variable>
-
     <xsl:choose>
-      <xsl:when test="$passivetex.extensions != '0'">
-        <fotex:sort xmlns:fotex="http://www.tug.org/fotex">
-          <xsl:copy-of select="$page-number-citations"/>
-        </fotex:sort>
+      <xsl:when test="$xep.extensions != 0">
+        <xsl:if test="$refs[not(see) and not(seealso) and not(secondary)]">
+          <xsl:text>, </xsl:text>
+          <rx:page-index>
+            <rx:index-item xsl:use-attribute-sets="xep.index.item.properties">
+              <xsl:attribute name="ref-key">
+                <xsl:value-of select="primary"/>
+              </xsl:attribute>
+            </rx:index-item>
+          </rx:page-index>        
+        </xsl:if>
       </xsl:when>
       <xsl:otherwise>
-        <xsl:copy-of select="$page-number-citations"/>
+        <xsl:variable name="page-number-citations">
+          <xsl:for-each select="$refs[not(see) and not(seealso)
+                                and not(secondary)]">
+            <xsl:apply-templates select="." mode="reference">
+              <xsl:with-param name="scope" select="$scope"/>
+            </xsl:apply-templates>
+          </xsl:for-each>
+        </xsl:variable>
+
+        <xsl:choose>
+          <xsl:when test="$passivetex.extensions != '0'">
+            <fotex:sort xmlns:fotex="http://www.tug.org/fotex">
+              <xsl:copy-of select="$page-number-citations"/>
+            </fotex:sort>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:copy-of select="$page-number-citations"/>
+          </xsl:otherwise>
+        </xsl:choose>
       </xsl:otherwise>
     </xsl:choose>
+
+    <xsl:if test="$refs[not(secondary)]/*[self::see]">
+      <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &sep;, &sep;, see))[&scope;][1])]"
+                           mode="index-see">
+         <xsl:with-param name="scope" select="$scope"/>
+         <xsl:sort select="translate(see, &lowercase;, &uppercase;)"/>
+      </xsl:apply-templates>
+    </xsl:if>
+
   </fo:block>
 
   <xsl:if test="$refs/secondary or $refs[not(secondary)]/*[self::seealso]">
   <fo:block>
     <xsl:value-of select="secondary"/>
 
-    <xsl:variable name="page-number-citations">
-      <xsl:for-each select="$refs[not(see) and not(seealso)
-                            and not(tertiary)]">
-        <xsl:apply-templates select="." mode="reference">
-          <xsl:with-param name="scope" select="$scope"/>
-        </xsl:apply-templates>
-      </xsl:for-each>
-
-      <xsl:if test="$refs[not(tertiary)]/*[self::see]">
-        <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &secondary;, &sep;, &sep;, see))[&scope;][1])]"
-                             mode="index-see">
-          <xsl:with-param name="scope" select="$scope"/>
-          <xsl:sort select="translate(see, &lowercase;, &uppercase;)"/>
-        </xsl:apply-templates>
-      </xsl:if>
-    </xsl:variable>
-
     <xsl:choose>
-      <xsl:when test="$passivetex.extensions != '0'">
-        <fotex:sort xmlns:fotex="http://www.tug.org/fotex">
-          <xsl:copy-of select="$page-number-citations"/>
-        </fotex:sort>
+      <xsl:when test="$xep.extensions != 0">
+        <xsl:if test="$refs[not(see) and not(seealso) and not(tertiary)]">
+          <xsl:text>, </xsl:text>
+          <rx:page-index>
+            <rx:index-item xsl:use-attribute-sets="xep.index.item.properties">
+              <xsl:attribute name="ref-key">
+                <xsl:value-of select="primary"/>
+                <xsl:text>, </xsl:text>
+                <xsl:value-of select="secondary"/>
+              </xsl:attribute>
+            </rx:index-item>
+          </rx:page-index>
+        </xsl:if>
       </xsl:when>
       <xsl:otherwise>
-        <xsl:copy-of select="$page-number-citations"/>
+        <xsl:variable name="page-number-citations">
+          <xsl:for-each select="$refs[not(see) and not(seealso)
+                                and not(tertiary)]">
+            <xsl:apply-templates select="." mode="reference">
+              <xsl:with-param name="scope" select="$scope"/>
+            </xsl:apply-templates>
+          </xsl:for-each>
+        </xsl:variable>
+
+        <xsl:choose>
+          <xsl:when test="$passivetex.extensions != '0'">
+            <fotex:sort xmlns:fotex="http://www.tug.org/fotex">
+              <xsl:copy-of select="$page-number-citations"/>
+            </fotex:sort>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:copy-of select="$page-number-citations"/>
+          </xsl:otherwise>
+        </xsl:choose>
       </xsl:otherwise>
     </xsl:choose>
+
+    <xsl:if test="$refs[not(tertiary)]/*[self::see]">
+      <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &secondary;, &sep;, &sep;, see))[&scope;][1])]"
+                           mode="index-see">
+        <xsl:with-param name="scope" select="$scope"/>
+        <xsl:sort select="translate(see, &lowercase;, &uppercase;)"/>
+      </xsl:apply-templates>
+    </xsl:if>
+
   </fo:block>
 
   <xsl:if test="$refs/tertiary or $refs[not(tertiary)]/*[self::seealso]">
   <fo:block>
     <xsl:value-of select="tertiary"/>
 
-    <xsl:variable name="page-number-citations">
-      <xsl:for-each select="$refs[not(see) and not(seealso)]">
-        <xsl:apply-templates select="." mode="reference">
-          <xsl:with-param name="scope" select="$scope"/>
-        </xsl:apply-templates>
-      </xsl:for-each>
-
-      <xsl:if test="$refs/see">
-        <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, see))[&scope;][1])]"
-                             mode="index-see">
-          <xsl:with-param name="scope" select="$scope"/>
-          <xsl:sort select="translate(see, &lowercase;, &uppercase;)"/>
-        </xsl:apply-templates>
-      </xsl:if>
-    </xsl:variable>
-
     <xsl:choose>
-      <xsl:when test="$passivetex.extensions != '0'">
-        <fotex:sort xmlns:fotex="http://www.tug.org/fotex">
-          <xsl:copy-of select="$page-number-citations"/>
-        </fotex:sort>
+      <xsl:when test="$xep.extensions != 0">
+        <xsl:if test="$refs[not(see) and not(seealso)]">
+          <xsl:text>, </xsl:text>
+          <rx:page-index>
+            <rx:index-item xsl:use-attribute-sets="xep.index.item.properties">
+              <xsl:attribute name="ref-key">
+                <xsl:value-of select="primary"/>
+                <xsl:text>, </xsl:text>
+                <xsl:value-of select="secondary"/>
+                <xsl:text>, </xsl:text>
+                <xsl:value-of select="tertiary"/>
+              </xsl:attribute>
+            </rx:index-item>
+          </rx:page-index>
+        </xsl:if>
       </xsl:when>
       <xsl:otherwise>
-        <xsl:copy-of select="$page-number-citations"/>
+        <xsl:variable name="page-number-citations">
+          <xsl:for-each select="$refs[not(see) and not(seealso)]">
+            <xsl:apply-templates select="." mode="reference">
+              <xsl:with-param name="scope" select="$scope"/>
+            </xsl:apply-templates>
+          </xsl:for-each>
+        </xsl:variable>
+
+        <xsl:choose>
+          <xsl:when test="$passivetex.extensions != '0'">
+            <fotex:sort xmlns:fotex="http://www.tug.org/fotex">
+              <xsl:copy-of select="$page-number-citations"/>
+            </fotex:sort>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:copy-of select="$page-number-citations"/>
+          </xsl:otherwise>
+        </xsl:choose>
       </xsl:otherwise>
     </xsl:choose>
+
+    <xsl:if test="$refs/see">
+      <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, see))[&scope;][1])]"
+                           mode="index-see">
+        <xsl:with-param name="scope" select="$scope"/>
+        <xsl:sort select="translate(see, &lowercase;, &uppercase;)"/>
+      </xsl:apply-templates>
+    </xsl:if>
+
   </fo:block>
 
   <xsl:if test="$refs/seealso">
index c068647a9afb0125d606775a1351053c643a138e..8a9b285b48efb83e0b32c837271d312637df429d 100644 (file)
@@ -1,6 +1,7 @@
 <?xml version='1.0'?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 xmlns:fo="http://www.w3.org/1999/XSL/Format"
+                xmlns:rx="http://www.renderx.com/XSL/Extensions"
                 version='1.0'>
 
 <!-- ********************************************************************
 
 <!-- ==================================================================== -->
 
-<xsl:template match="indexterm">
+<xsl:template match="indexterm" name="indexterm">
   <fo:wrapper>
     <xsl:attribute name="id">
       <xsl:call-template name="object.id"/>
     </xsl:attribute>
-    <xsl:comment>
-      <xsl:call-template name="comment-escape-string">
-        <xsl:with-param name="string">
+    <xsl:choose>
+      <xsl:when test="$xep.extensions != 0">
+        <xsl:attribute name="rx:key">
           <xsl:value-of select="primary"/>
           <xsl:if test="secondary">
             <xsl:text>, </xsl:text>
             <xsl:text>, </xsl:text>
             <xsl:value-of select="tertiary"/>
           </xsl:if>
-        </xsl:with-param>
-      </xsl:call-template>
-    </xsl:comment>
+        </xsl:attribute>        
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:comment>
+          <xsl:call-template name="comment-escape-string">
+            <xsl:with-param name="string">
+              <xsl:value-of select="primary"/>
+              <xsl:if test="secondary">
+                <xsl:text>, </xsl:text>
+                <xsl:value-of select="secondary"/>
+              </xsl:if>
+              <xsl:if test="tertiary">
+                <xsl:text>, </xsl:text>
+                <xsl:value-of select="tertiary"/>
+              </xsl:if>
+            </xsl:with-param>
+          </xsl:call-template>
+        </xsl:comment>
+      </xsl:otherwise>
+    </xsl:choose>
   </fo:wrapper>
 </xsl:template>
 
+<xsl:template match="indexterm[@class='startofrange']">
+  <xsl:choose>
+    <xsl:when test="$xep.extensions != 0">
+      <rx:begin-index-range>
+        <xsl:attribute name="id">
+          <xsl:value-of select="@id"/>
+        </xsl:attribute>
+        
+        <xsl:attribute name="rx:key">
+          <xsl:value-of select="primary"/>
+          <xsl:if test="secondary">
+            <xsl:text>, </xsl:text>
+            <xsl:value-of select="secondary"/>
+          </xsl:if>
+          <xsl:if test="tertiary">
+            <xsl:text>, </xsl:text>
+            <xsl:value-of select="tertiary"/>
+          </xsl:if>
+        </xsl:attribute>
+      </rx:begin-index-range>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:call-template name="indexterm"/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="indexterm[@class='endofrange']">
+  <xsl:choose>
+    <xsl:when test="$xep.extensions != 0">
+      <rx:end-index-range>
+        <xsl:attribute name="ref-id">
+          <xsl:value-of select="@startref"/>
+        </xsl:attribute>
+      </rx:end-index-range>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:call-template name="indexterm"/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
 <!-- ==================================================================== -->
 
 <xsl:template match="indexentry">
index 075b2c45d3cd8edd46b4f3336c9ece47e0f8ebb7..9d89e2de4652eddf3a21cae146fd153e90adff95 100644 (file)
 <!ENTITY variablelist.as.blocks SYSTEM "../params/variablelist.as.blocks.xml">
 <!ENTITY verbatim.properties SYSTEM "../params/verbatim.properties.xml">
 <!ENTITY xep.extensions SYSTEM "../params/xep.extensions.xml">
+<!ENTITY xep.index.item.properties SYSTEM "../params/xep.index.item.properties.xml">
 <!ENTITY xref.properties SYSTEM "../params/xref.properties.xml">
 <!ENTITY sidebar.properties SYSTEM "../params/sidebar.properties.xml">
 <!ENTITY menuchoice.separator SYSTEM "../params/menuchoice.separator.xml">
index f1b6b9b12ed5426fdc759273e58cc2d2c0fd6d49..5e95248669df3cd47bea8e2632d1b635f0ad3930 100644 (file)
@@ -89,6 +89,7 @@ to be incomplete. Don't forget to read the source, too :-)</para>
 &generate.toc;
 &generate.index;
 &make.index.markup;
+&xep.index.item.properties;
 &toc.section.depth;
 &toc.indent.width;
 &toc.margin.properties;
@@ -642,6 +643,7 @@ around all these parameters.</para>
 <src:fragref linkend="variablelist.as.blocks.frag"/>
 <src:fragref linkend="verbatim.properties.frag"/>
 <src:fragref linkend="xep.extensions.frag"/>
+<src:fragref linkend="xep.index.item.properties.frag"/>
 <src:fragref linkend="xref.properties.frag"/>
 <src:fragref linkend="xref.with.number.and.title.frag"/>
 
diff --git a/xsl/params/xep.index.item.properties.xml b/xsl/params/xep.index.item.properties.xml
new file mode 100644 (file)
index 0000000..5d57201
--- /dev/null
@@ -0,0 +1,23 @@
+<refentry id="xep.index.item.properties">
+<refnamediv>
+<refname>xep.index.item.properties</refname>
+<refpurpose>Properties associated with XEP index-items</refpurpose>
+</refnamediv>
+
+<refsynopsisdiv>
+<src:fragment id='xep.index.item.properties.frag'>
+<xsl:attribute-set name="xep.index.item.properties">
+  <xsl:attribute name="merge-subsequent-page-numbers">true</xsl:attribute>
+  <xsl:attribute name="link-back">true</xsl:attribute>
+</xsl:attribute-set>
+</src:fragment>
+</refsynopsisdiv>
+
+<refsect1><title>Description</title>
+
+<para>Properties associated with XEP index-items. For more info see
+<ulink
+url="http://xep.xattic.com/xep/spec.html#N6836">http://xep.xattic.com/xep/spec.html</ulink>.</para>
+
+</refsect1>
+</refentry>