From 11dad6fa5d9dfaf60d03724dc4c068b90ccdae09 Mon Sep 17 00:00:00 2001
From: Norman Walsh <ndw@nwalsh.com>
Date: Thu, 26 Apr 2001 15:20:49 +0000
Subject: [PATCH] Improve procedure step/substep enumeration

---
 xsl/fo/lists.xsl   | 24 +++++++++++++++++++++++-
 xsl/html/lists.xsl | 16 +++++++++++++++-
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/xsl/fo/lists.xsl b/xsl/fo/lists.xsl
index 4889c72c6..bdfd9b0dc 100644
--- a/xsl/fo/lists.xsl
+++ b/xsl/fo/lists.xsl
@@ -361,10 +361,32 @@
 </xsl:template>
 
 <xsl:template match="step">
+  <xsl:variable name="depth" select="count(ancestor::substeps)"/>
+  <xsl:variable name="type" select="$depth mod 5"/>
+
   <fo:list-item>
     <fo:list-item-label end-indent="label-end()">
       <fo:block>
-        <xsl:number count="step" format="1."/>
+        <xsl:choose>
+          <xsl:when test="$depth = 0">
+            <xsl:number count="step" format="1."/>
+          </xsl:when>
+          <xsl:when test="$type = 1">
+            <xsl:number count="step" format="a."/>
+          </xsl:when>
+          <xsl:when test="$type = 2">
+            <xsl:number count="step" format="i."/>
+          </xsl:when>
+          <xsl:when test="$type = 3">
+            <xsl:number count="step" format="A."/>
+          </xsl:when>
+          <xsl:when test="$type = 4">
+            <xsl:number count="step" format="I."/>
+          </xsl:when>
+          <xsl:when test="$type = 0">
+            <xsl:number count="step" format="1."/>
+          </xsl:when>
+        </xsl:choose>
       </fo:block>
     </fo:list-item-label>
     <fo:list-item-body start-indent="body-start()">
diff --git a/xsl/html/lists.xsl b/xsl/html/lists.xsl
index bca4f31bc..095ad5940 100644
--- a/xsl/html/lists.xsl
+++ b/xsl/html/lists.xsl
@@ -424,7 +424,21 @@
 </xsl:template>
 
 <xsl:template match="substeps">
-  <ol><xsl:apply-templates/></ol>
+  <xsl:variable name="depth" select="count(ancestor::substeps)"/>
+  <xsl:variable name="type" select="$depth mod 5"/>
+  <xsl:variable name="numeration">
+    <xsl:choose>
+      <xsl:when test="$type = 0">a</xsl:when>
+      <xsl:when test="$type = 1">i</xsl:when>
+      <xsl:when test="$type = 2">A</xsl:when>
+      <xsl:when test="$type = 3">I</xsl:when>
+      <xsl:when test="$type = 4">1</xsl:when>
+    </xsl:choose>
+  </xsl:variable>
+
+  <ol type="{$numeration}">
+    <xsl:apply-templates/>
+  </ol>
 </xsl:template>
 
 <xsl:template match="step">
-- 
2.40.0