]> granicus.if.org Git - docbook-dsssl/commitdiff
Use common code to calculate step numbers; support xref to procedures and steps;...
authorNorman Walsh <ndw@nwalsh.com>
Thu, 21 Jun 2001 13:38:34 +0000 (13:38 +0000)
committerNorman Walsh <ndw@nwalsh.com>
Thu, 21 Jun 2001 13:38:34 +0000 (13:38 +0000)
xsl/common/common.xsl
xsl/common/gentext.xsl
xsl/common/labels.xsl
xsl/common/titles.xsl
xsl/fo/lists.xsl
xsl/fo/param.xsl
xsl/fo/xref.xsl
xsl/html/lists.xsl
xsl/html/param.xsl
xsl/html/xref.xsl

index b9901a680b700048b146f376afca1244044551b6..851a17ecb59a0a16b872757e2d490849ad302201 100644 (file)
@@ -994,6 +994,65 @@ pointed to by the link is one of the elements listed in
   </xsl:if>
 </xsl:template>
 
+<!-- ====================================================================== -->
+<!-- Procedure Step Numeration -->
+
+<xsl:param name="procedure.step.numeration.formats" select="'1aiAI'"/>
+
+<xsl:template name="procedure.step.numeration">
+  <xsl:param name="context" select="."/>
+  <xsl:variable name="format.length"
+                select="string-length($procedure.step.numeration.formats)"/>
+  <xsl:choose>
+    <xsl:when test="local-name($context) = 'substeps'">
+      <xsl:variable name="ssdepth"
+                    select="count($context/ancestor::substeps)"/>
+      <xsl:variable name="sstype" select="($ssdepth mod $format.length)+2"/>
+      <xsl:choose>
+        <xsl:when test="$sstype &gt; $format.length">
+          <xsl:value-of select="substring($procedure.step.numeration.formats,1,1)"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:value-of select="substring($procedure.step.numeration.formats,$sstype,1)"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:when>
+    <xsl:when test="local-name($context) = 'step'">
+      <xsl:variable name="sdepth"
+                    select="count($context/ancestor::substeps)"/>
+      <xsl:variable name="stype" select="($sdepth mod $format.length)+1"/>
+      <xsl:value-of select="substring($procedure.step.numeration.formats,$stype,1)"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:message>
+        <xsl:text>Unexpected context in procedure.step.numeration: </xsl:text>
+        <xsl:value-of select="local-name($context)"/>
+      </xsl:message>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="step" mode="number">
+  <xsl:param name="rest" select="''"/>
+  <xsl:param name="recursive" select="1"/>
+  <xsl:variable name="format">
+    <xsl:call-template name="procedure.step.numeration"/>
+  </xsl:variable>
+  <xsl:variable name="num">
+    <xsl:number count="step" format="{$format}"/>
+  </xsl:variable>
+  <xsl:choose>
+    <xsl:when test="$recursive != 0 and ancestor::step">
+      <xsl:apply-templates select="ancestor::step[1]" mode="number">
+        <xsl:with-param name="rest" select="concat('.', $num, $rest)"/>
+      </xsl:apply-templates>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:value-of select="concat($num, $rest)"/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
 <!-- ====================================================================== -->
 
 </xsl:stylesheet>
index ec3f9a3b313ed978ce090f5fc23f9e533c50b43b..b62b66fe492320a67bf96151a5409ec82e8ae9b0 100644 (file)
   </xsl:choose>
 </xsl:template>
 
+<xsl:template match="procedure" mode="object.title.template">
+  <xsl:choose>
+    <xsl:when test="$formal.procedures != 0">
+      <xsl:call-template name="gentext.template">
+        <xsl:with-param name="context" select="'title'"/>
+        <xsl:with-param name="name" select="'procedure.formal'"/>
+      </xsl:call-template>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:call-template name="gentext.template">
+        <xsl:with-param name="context" select="'title'"/>
+        <xsl:with-param name="name" select="local-name(.)"/>
+      </xsl:call-template>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
 <xsl:template match="article/appendix"
               mode="object.title.template">
   <!-- FIXME: HACK HACK HACK! -->
index a19c23d50d301b26c56d6cef8097a364ff3eab47..9d534c91079b628628b281a683f479823cbe07c1 100644 (file)
@@ -460,7 +460,8 @@ element label.</para>
   </xsl:if>
 </xsl:template>
 
-<xsl:template match="figure|table|example|equation" mode="label.markup">
+<xsl:template match="figure|table|example|equation|procedure"
+              mode="label.markup">
   <xsl:variable name="pchap"
                 select="ancestor::chapter|ancestor::appendix"/>
 
index 2c5e8c27572afd148709e1dd9c7cfdd02f274a61..b915a12c59e1bd6fe1c55a2b10a8c13164077e25 100644 (file)
@@ -254,6 +254,13 @@ title of the element. This does not include the label.
   </xsl:apply-templates>
 </xsl:template>
 
+<xsl:template match="procedure" mode="title.markup">
+  <xsl:param name="allow-anchors" select="'0'"/>
+  <xsl:apply-templates select="title" mode="title.markup">
+    <xsl:with-param name="allow-anchors" select="$allow-anchors"/>
+  </xsl:apply-templates>
+</xsl:template>
+
 <xsl:template match="abstract" mode="title.markup">
   <xsl:param name="allow-anchors" select="'0'"/>
   <xsl:choose>
index bdfd9b0dcdd6026c42134d7db53a99ce927c1b16..9b29539fa9f26359020785a3ab413d202822c08c 100644 (file)
 <!-- ==================================================================== -->
 
 <xsl:template match="procedure">
+  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
   <xsl:variable name="title" select="title"/>
   <xsl:variable name="preamble"
                 select="*[not(self::step or self::title)]"/>
   <xsl:variable name="steps" select="step"/>
 
-  <fo:block space-before.optimum="1em"
+  <fo:block id="{$id}"
+            space-before.optimum="1em"
             space-before.minimum="0.8em"
             space-before.maximum="1.2em">
     <xsl:if test="./title">
 </xsl:template>
 
 <xsl:template match="step">
-  <xsl:variable name="depth" select="count(ancestor::substeps)"/>
-  <xsl:variable name="type" select="$depth mod 5"/>
-
+  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
   <fo:list-item>
     <fo:list-item-label end-indent="label-end()">
-      <fo:block>
-        <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 id="{$id}">
+        <xsl:apply-templates select="." mode="number">
+          <xsl:with-param name="recursive" select="0"/>
+        </xsl:apply-templates>
       </fo:block>
     </fo:list-item-label>
     <fo:list-item-body start-indent="body-start()">
index 903af931cd3cb96bddee8fcd1c55d09fbd8188c3..668af6d16ed48945600ef128e5839333fbd0e246 100644 (file)
@@ -1177,5 +1177,16 @@ they will be numbered monotonically throughout each
 </refdescription>
 </doc:param>
 
+<!-- ==================================================================== -->
+<xsl:param name="formal.procedures" select="1" doc:type='boolean'/>
+
+<doc:param name="formal.procedures" xmlns="">
+<refpurpose>Selects formal or informal procedures</refpurpose>
+<refdescription>
+<para>Formal procedures are numbered and always hav a title.
+</para>
+</refdescription>
+</doc:param>
+
 </xsl:stylesheet>
 
index d7dc41c3e75483b2c487b9aeaa0af159f97a4cf7..1a8e221e9b60d5a202f928ddbe27ef52b1ed0dba 100644 (file)
   <xsl:apply-templates select="." mode="object.xref.markup"/>
 </xsl:template>
 
+<xsl:template match="procedure" mode="xref-to">
+  <xsl:apply-templates select="." mode="object.xref.markup"/>
+</xsl:template>
+
 <xsl:template match="cmdsynopsis" mode="xref-to">
   <xsl:apply-templates select="(.//command)[1]" mode="xref"/>
 </xsl:template>
   <xsl:apply-templates select="." mode="object.xref.markup"/>
 </xsl:template>
 
+<xsl:template match="step" mode="xref-to">
+  <xsl:call-template name="gentext">
+    <xsl:with-param name="key" select="'Step'"/>
+  </xsl:call-template>
+  <xsl:text> </xsl:text>
+  <xsl:apply-templates select="." mode="number"/>
+</xsl:template>
+
 <xsl:template match="co" mode="xref-to">
   <xsl:apply-templates select="." mode="callout-bug"/>
 </xsl:template>
index 7a9d1c35969844e360710916ad448a937944392f..f35cc7a58a0670e81cfd737182ee3fad36265c71 100644 (file)
 <!-- ==================================================================== -->
 
 <xsl:template match="procedure">
-  <xsl:variable name="id">
-    <xsl:call-template name="object.id"/>
-  </xsl:variable>
   <div class="{name(.)}">
-    <a name="{$id}"/>
-    <xsl:if test="title">
-      <xsl:apply-templates select="title" mode="procedure.title.mode"/>
+    <xsl:if test="title or $formal.procedures != 0">
+      <xsl:call-template name="formal.object.heading"/>
     </xsl:if>
-    <xsl:apply-templates select="*[local-name()!='step']"/>     
-    <ol><xsl:apply-templates select="step"/></ol>              
+    <xsl:apply-templates select="*[local-name()!='step']"/>
+    <ol>
+      <xsl:attribute name="type">
+        <xsl:value-of select="substring($procedure.step.numeration.formats,1,1)"/>
+      </xsl:attribute>
+      <xsl:apply-templates select="step"/>
+    </ol>
   </div>
 </xsl:template>
 
 </xsl:template>
 
 <xsl:template match="substeps">
-  <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:call-template name="procedure.step.numeration"/>
   </xsl:variable>
 
   <ol type="{$numeration}">
index b36aec408056c8ccb7628bb5b73f7ebb9b2d7085..6c73d6b533f06d270e505c143b17f8bab3d80809 100644 (file)
@@ -1148,5 +1148,15 @@ in default.encoding, set this parameter to value <literal>native</literal>.
 </refdescription>
 </doc:param>
 
+<!-- ==================================================================== -->
+<xsl:param name="formal.procedures" select="1" doc:type='boolean'/>
+
+<doc:param name="formal.procedures" xmlns="">
+<refpurpose>Selects formal or informal procedures</refpurpose>
+<refdescription>
+<para>Formal procedures are numbered and always hav a title.
+</para>
+</refdescription>
+</doc:param>
 
 </xsl:stylesheet>
index f022a5de003c8bfcae250e9096e6ab49117188bb..f3612da938a874c2e7bd861d88294eb7550e937f 100644 (file)
   <xsl:apply-templates select="." mode="object.xref.markup"/>
 </xsl:template>
 
+<xsl:template match="procedure" mode="xref-to">
+  <xsl:apply-templates select="." mode="object.xref.markup"/>
+</xsl:template>
+
 <xsl:template match="cmdsynopsis" mode="xref-to">
   <xsl:apply-templates select="(.//command)[1]" mode="xref"/>
 </xsl:template>
   <xsl:apply-templates select="." mode="object.xref.markup"/>
 </xsl:template>
 
+<xsl:template match="step" mode="xref-to">
+  <xsl:call-template name="gentext">
+    <xsl:with-param name="key" select="'Step'"/>
+  </xsl:call-template>
+  <xsl:text> </xsl:text>
+  <xsl:apply-templates select="." mode="number"/>
+</xsl:template>
+
 <xsl:template match="co" mode="xref-to">
   <xsl:apply-templates select="." mode="callout-bug"/>
 </xsl:template>
   <xsl:value-of select="$title"/>
 </xsl:template>
 
+<xsl:template match="step" mode="xref-title">
+  <xsl:call-template name="gentext">
+    <xsl:with-param name="key" select="'Step'"/>
+  </xsl:call-template>
+  <xsl:text> </xsl:text>
+  <xsl:apply-templates select="." mode="number"/>
+</xsl:template>
+
 <xsl:template match="co" mode="xref-title">
   <xsl:variable name="title">
     <xsl:apply-templates select="." mode="callout-bug"/>