]> granicus.if.org Git - docbook-dsssl/commitdiff
Support continuation of orderedlists and inherited numeration in FO
authorNorman Walsh <ndw@nwalsh.com>
Wed, 2 Oct 2002 12:11:51 +0000 (12:11 +0000)
committerNorman Walsh <ndw@nwalsh.com>
Wed, 2 Oct 2002 12:11:51 +0000 (12:11 +0000)
xsl/fo/lists.xsl
xsl/html/lists.xsl

index 4b9fa1e990bb35c4b8acec762985dc4306c6be1f..4ddd54c0b68ada550e5e4c02f250f1960b5cc9f9 100644 (file)
 <!-- ==================================================================== -->
 
 <xsl:template match="itemizedlist">
-  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
+  <xsl:variable name="id">
+    <xsl:call-template name="object.id"/>
+  </xsl:variable>
+
+  <xsl:variable name="label-width">
+    <xsl:call-template name="dbfo-attribute">
+      <xsl:with-param name="pis"
+                      select="processing-instruction('dbfo')"/>
+      <xsl:with-param name="attribute" select="'label-width'"/>
+    </xsl:call-template>
+  </xsl:variable>
 
   <xsl:if test="title">
     <xsl:apply-templates select="title" mode="list.title.mode"/>
   <xsl:apply-templates select="*[not(self::listitem or self::title)]"/>
 
   <fo:list-block id="{$id}" xsl:use-attribute-sets="list.block.spacing"
-                 provisional-distance-between-starts="1.5em"
                  provisional-label-separation="0.2em">
+    <xsl:attribute name="provisional-distance-between-starts">
+      <xsl:choose>
+        <xsl:when test="$label-width != ''">
+          <xsl:value-of select="$label-width"/>
+        </xsl:when>
+        <xsl:otherwise>1.5em</xsl:otherwise>
+      </xsl:choose>
+    </xsl:attribute>
     <xsl:apply-templates select="listitem"/>
   </fo:list-block>
 </xsl:template>
 </xsl:template>
 
 <xsl:template match="orderedlist">
-  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
+  <xsl:variable name="id">
+    <xsl:call-template name="object.id"/>
+  </xsl:variable>
+
+  <xsl:variable name="label-width">
+    <xsl:call-template name="dbfo-attribute">
+      <xsl:with-param name="pis"
+                      select="processing-instruction('dbfo')"/>
+      <xsl:with-param name="attribute" select="'label-width'"/>
+    </xsl:call-template>
+  </xsl:variable>
 
   <xsl:if test="title">
     <xsl:apply-templates select="title" mode="list.title.mode"/>
   <xsl:apply-templates select="*[not(self::listitem or self::title)]"/>
 
   <fo:list-block id="{$id}" xsl:use-attribute-sets="list.block.spacing"
-                 provisional-distance-between-starts="2em"
                  provisional-label-separation="0.2em">
+    <xsl:attribute name="provisional-distance-between-starts">
+      <xsl:choose>
+        <xsl:when test="$label-width != ''">
+          <xsl:value-of select="$label-width"/>
+        </xsl:when>
+        <xsl:otherwise>2em</xsl:otherwise>
+      </xsl:choose>
+    </xsl:attribute>
     <xsl:apply-templates select="listitem"/>
   </fo:list-block>
 </xsl:template>
 
-<xsl:template match="orderedlist/listitem">
-  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
-
+<xsl:template match="orderedlist/listitem" mode="item-number">
   <xsl:variable name="numeration">
     <xsl:call-template name="list.numeration">
       <xsl:with-param name="node" select="parent::orderedlist"/>
     </xsl:choose>
   </xsl:variable>
 
+  <xsl:variable name="item-number">
+    <xsl:call-template name="orderedlist-item-number"/>
+  </xsl:variable>
+
+  <xsl:if test="parent::orderedlist/@inheritnum='inherit'
+                and ancestor::listitem[parent::orderedlist]">
+    <xsl:apply-templates select="ancestor::listitem[parent::orderedlist][1]"
+                         mode="item-number"/>
+  </xsl:if>
+
+  <xsl:number value="$item-number" format="{$type}"/>
+</xsl:template>
+
+<xsl:template match="orderedlist/listitem">
+  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
+
   <xsl:variable name="item.contents">
     <fo:list-item-label end-indent="label-end()">
       <fo:block>
-        <xsl:choose>
-          <xsl:when test="@override">
-            <xsl:number value="@override" format="{$type}"/>
-          </xsl:when>
-          <xsl:otherwise>
-            <xsl:number count="listitem" format="{$type}"/>
-          </xsl:otherwise>
-        </xsl:choose>
+        <xsl:apply-templates select="." mode="item-number"/>
       </fo:block>
     </fo:list-item-label>
     <fo:list-item-body start-indent="body-start()">
index 9edc735ff3f9f1e9c279a8929844c2b0f1bfa59d..c51059186ebb0f77384818c85919ef9b40642f05 100644 (file)
   </li>
 </xsl:template>
 
-<xsl:template name="orderedlist-starting-number">
-  <xsl:param name="list" select="."/>
-  <xsl:choose>
-    <xsl:when test="$list/@continuation != 'continues'">1</xsl:when>
-    <xsl:otherwise>
-      <xsl:variable name="prevlist"
-                    select="$list/preceding::orderedlist[1]"/>
-      <xsl:choose>
-        <xsl:when test="count($prevlist) = 0">2</xsl:when>
-        <xsl:otherwise>
-          <xsl:variable name="prevlength" select="count($prevlist/listitem)"/>
-          <xsl:variable name="prevstart">
-            <xsl:call-template name="orderedlist-starting-number">
-              <xsl:with-param name="list" select="$prevlist"/>
-            </xsl:call-template>
-          </xsl:variable>
-          <xsl:value-of select="$prevstart + $prevlength"/>
-        </xsl:otherwise>
-      </xsl:choose>
-    </xsl:otherwise>
-  </xsl:choose>
-</xsl:template>
-
 <xsl:template match="orderedlist">
   <xsl:variable name="start">
     <xsl:choose>