]> granicus.if.org Git - docbook-dsssl/commitdiff
Support formal.title.placement
authorNorman Walsh <ndw@nwalsh.com>
Thu, 14 Mar 2002 13:48:09 +0000 (13:48 +0000)
committerNorman Walsh <ndw@nwalsh.com>
Thu, 14 Mar 2002 13:48:09 +0000 (13:48 +0000)
xsl/fo/formal.xsl
xsl/fo/lists.xsl
xsl/fo/param.ent
xsl/fo/param.xweb
xsl/html/formal.xsl
xsl/html/lists.xsl
xsl/html/param.ent
xsl/html/param.xweb
xsl/params/formal.title.placement.xml [new file with mode: 0644]

index afbb85e46f555395cf0ff2b4484f86558c8d1940..0c8f2bc6fdcda85be3433f4fd9f9a26474ddc38a 100644 (file)
      ******************************************************************** -->
 
 <xsl:template name="formal.object">
+  <xsl:param name="placement" select="'before'"/>
+
   <xsl:variable name="id">
     <xsl:call-template name="object.id"/>
   </xsl:variable>
 
   <fo:block id="{$id}"
             xsl:use-attribute-sets="formal.object.properties">
-    <xsl:call-template name="formal.object.heading"/>
+    <xsl:if test="$placement = 'before'">
+      <xsl:call-template name="formal.object.heading"/>
+    </xsl:if>
     <xsl:apply-templates/>
+    <xsl:if test="$placement != 'before'">
+      <xsl:call-template name="formal.object.heading"/>
+    </xsl:if>
   </fo:block>
 </xsl:template>
 
 </xsl:template>
 
 <xsl:template name="semiformal.object">
+  <xsl:param name="placement" select="'before'"/>
   <xsl:choose>
     <xsl:when test="./title">
-      <xsl:call-template name="formal.object"/>
+      <xsl:call-template name="formal.object">
+        <xsl:with-param name="placement" select="$placement"/>
+      </xsl:call-template>
     </xsl:when>
     <xsl:otherwise>
       <xsl:call-template name="informal.object"/>
 </xsl:template>
 
 <xsl:template match="figure">
+  <xsl:variable name="param.placement"
+                select="substring-after(normalize-space($formal.title.placement),
+                                        concat(local-name(.), ' '))"/>
+
+  <xsl:variable name="placement">
+    <xsl:choose>
+      <xsl:when test="contains($param.placement, ' ')">
+        <xsl:value-of select="substring-before($param.placement, ' ')"/>
+      </xsl:when>
+      <xsl:when test="$param.placement = ''">before</xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="$param.placement"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
   <!-- FIXME: is this too careless? -->
   <xsl:choose>
     <xsl:when test=".//imagedata[@align][1]">
       <fo:block text-align="{.//imagedata[@align][1]/@align}">
-        <xsl:call-template name="formal.object"/>
+        <xsl:call-template name="formal.object">
+          <xsl:with-param name="placement" select="$placement"/>
+        </xsl:call-template>
       </fo:block>
     </xsl:when>
     <xsl:otherwise>
-      <xsl:call-template name="formal.object"/>
+      <xsl:call-template name="formal.object">
+        <xsl:with-param name="placement" select="$placement"/>
+      </xsl:call-template>
     </xsl:otherwise>
   </xsl:choose>
 </xsl:template>
 
 <xsl:template match="example">
-  <xsl:call-template name="formal.object"/>
+  <xsl:variable name="param.placement"
+                select="substring-after(normalize-space($formal.title.placement),
+                                        concat(local-name(.), ' '))"/>
+
+  <xsl:variable name="placement">
+    <xsl:choose>
+      <xsl:when test="contains($param.placement, ' ')">
+        <xsl:value-of select="substring-before($param.placement, ' ')"/>
+      </xsl:when>
+      <xsl:when test="$param.placement = ''">before</xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="$param.placement"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
+  <xsl:call-template name="formal.object">
+    <xsl:with-param name="placement" select="$placement"/>
+  </xsl:call-template>
 </xsl:template>
 
 <xsl:template name="table.frame">
     <xsl:call-template name="object.id"/>
   </xsl:variable>
 
+  <xsl:variable name="param.placement"
+                select="substring-after(normalize-space($formal.title.placement),
+                                        concat(local-name(.), ' '))"/>
+
+  <xsl:variable name="placement">
+    <xsl:choose>
+      <xsl:when test="contains($param.placement, ' ')">
+        <xsl:value-of select="substring-before($param.placement, ' ')"/>
+      </xsl:when>
+      <xsl:when test="$param.placement = ''">before</xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="$param.placement"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
   <xsl:variable name="prop-columns"
     select=".//colspec[contains(@colwidth, '*')]"/>
 
   <xsl:variable name="table.content">
-    <fo:table-and-caption id="{$id}"
-                          xsl:use-attribute-sets="formal.object.properties"
-                          keep-together.within-column="1">
-      <fo:table-caption>
-        <fo:block xsl:use-attribute-sets="formal.title.properties">
-          <xsl:apply-templates select="." mode="object.title.markup"/>
-        </fo:block>
-      </fo:table-caption>
+    <fo:block id="{$id}"
+              xsl:use-attribute-sets="formal.object.properties"
+              keep-together.within-column="1">
+
+      <xsl:if test="$placement = 'before'">
+        <xsl:call-template name="formal.object.heading"/>
+      </xsl:if>
+
       <fo:table>
         <xsl:call-template name="table.frame"/>
         <xsl:if test="count($prop-columns) != 0">
         </xsl:if>
         <xsl:apply-templates select="tgroup"/>
       </fo:table>
-    </fo:table-and-caption>
+
+      <xsl:if test="$placement != 'before'">
+        <xsl:call-template name="formal.object.heading"/>
+      </xsl:if>
+    </fo:block>
   </xsl:variable>
 
   <xsl:variable name="footnotes">
     <xsl:if test=".//footnote">
-      <fo:block>
+      <fo:block font-family="{$body.font.family}"
+                font-size="{$footnote.font.size}"
+                keep-together.within-column="1"
+                keep-with-previous="always">
         <xsl:apply-templates select=".//footnote" mode="table.footnote.mode"/>
       </fo:block>
     </xsl:if>
 </xsl:template>
 
 <xsl:template match="equation">
-  <xsl:call-template name="semiformal.object"/>
+  <xsl:variable name="param.placement"
+                select="substring-after(normalize-space($formal.title.placement),
+                                        concat(local-name(.), ' '))"/>
+
+  <xsl:variable name="placement">
+    <xsl:choose>
+      <xsl:when test="contains($param.placement, ' ')">
+        <xsl:value-of select="substring-before($param.placement, ' ')"/>
+      </xsl:when>
+      <xsl:when test="$param.placement = ''">before</xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="$param.placement"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
+  <xsl:call-template name="semiformal.object">
+    <xsl:with-param name="placement" select="$placement"/>
+  </xsl:call-template>
 </xsl:template>
 
 <xsl:template match="figure/title"></xsl:template>
   <xsl:variable name="footnotes">
     <xsl:if test=".//footnote">
       <fo:block font-family="{$body.font.family}"
-                font-size="{$footnote.font.size}">
+                font-size="{$footnote.font.size}"
+                keep-together.within-column="1"
+                keep-with-previous="always">
         <xsl:apply-templates select=".//footnote" mode="table.footnote.mode"/>
       </fo:block>
     </xsl:if>
index 6e60816a69664ef97042936e4d662707b21395ee..1f33b05e8d028f92d8eaff71624658f119f2517a 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="id">
+    <xsl:call-template name="object.id"/>
+  </xsl:variable>
+
+  <xsl:variable name="param.placement"
+                select="substring-after(normalize-space($formal.title.placement),
+                                        concat(local-name(.), ' '))"/>
+
+  <xsl:variable name="placement">
+    <xsl:choose>
+      <xsl:when test="contains($param.placement, ' ')">
+        <xsl:value-of select="substring-before($param.placement, ' ')"/>
+      </xsl:when>
+      <xsl:when test="$param.placement = ''">before</xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="$param.placement"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
   <xsl:variable name="preamble"
                 select="*[not(self::step or self::title)]"/>
   <xsl:variable name="steps" select="step"/>
 
   <fo:block id="{$id}" xsl:use-attribute-sets="list.block.spacing">
-    <xsl:if test="./title">
-      <fo:block font-weight="bold">
-        <xsl:apply-templates select="./title" mode="procedure.title.mode"/>
-      </fo:block>
+    <xsl:if test="./title and $placement = 'before'">
+      <xsl:choose>
+        <xsl:when test="$formal.procedures != 0">
+          <xsl:call-template name="formal.object.heading"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <fo:block font-weight="bold">
+            <xsl:apply-templates select="./title" mode="procedure.title.mode"/>
+          </fo:block>
+        </xsl:otherwise>
+      </xsl:choose>
     </xsl:if>
 
     <xsl:apply-templates select="$preamble"/>
                    provisional-label-separation="0.2em">
       <xsl:apply-templates select="$steps"/>
     </fo:list-block>
+
+    <xsl:if test="./title and $placement != 'before'">
+      <xsl:choose>
+        <xsl:when test="$formal.procedures != 0">
+          <xsl:call-template name="formal.object.heading"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <fo:block font-weight="bold">
+            <xsl:apply-templates select="./title" mode="procedure.title.mode"/>
+          </fo:block>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:if>
   </fo:block>
 </xsl:template>
 
index 09cb17da72c792723b485979e03107fbb554714a..cb91ce2f7fa41fd25d176048229091b115e113d9 100644 (file)
@@ -40,6 +40,7 @@
 <!ENTITY fop.extensions SYSTEM "../params/fop.extensions.xml">
 <!ENTITY formal.object.properties SYSTEM "../params/formal.object.properties.xml">
 <!ENTITY formal.procedures SYSTEM "../params/formal.procedures.xml">
+<!ENTITY formal.title.placement SYSTEM "../params/formal.title.placement.xml">
 <!ENTITY formal.title.properties SYSTEM "../params/formal.title.properties.xml">
 <!ENTITY funcsynopsis.decoration SYSTEM "../params/funcsynopsis.decoration.xml">
 <!ENTITY funcsynopsis.style SYSTEM "../params/funcsynopsis.style.xml">
index 7f0d50c661a19c1e0c2b70a1a85c37e07800357c..d93d484a4d3cf02b9c4f198af4b9fa8f3e095352 100644 (file)
@@ -180,6 +180,7 @@ to be incomplete. Don't forget to read the source, too :-)</para>
 <reference><title>Miscellaneous</title>
 &graphic.default.extension;
 &formal.procedures;
+&formal.title.placement;
 &runinhead.default.title.end.punct;
 &runinhead.title.end.punct;
 &show.comments;
@@ -410,6 +411,7 @@ around all these parameters.</para>
 <src:fragref linkend="fop.extensions.frag"/>
 <src:fragref linkend="formal.object.properties.frag"/>
 <src:fragref linkend="formal.procedures.frag"/>
+<src:fragref linkend="formal.title.placement.frag"/>
 <src:fragref linkend="formal.title.properties.frag"/>
 <src:fragref linkend="funcsynopsis.decoration.frag"/>
 <src:fragref linkend="funcsynopsis.style.frag"/>
index fda3c0d9111ba939a363536631ef53d9478aadc7..007fa857d586d6315dd242b08739e3f703ea8a16 100644 (file)
      ******************************************************************** -->
 
 <xsl:template name="formal.object">
+  <xsl:param name="placement" select="'before'"/>
+
   <div class="{name(.)}">
-    <xsl:call-template name="formal.object.heading"/>
-    <xsl:apply-templates/>
+    <xsl:call-template name="anchor"/>
+    <xsl:choose>
+      <xsl:when test="$placement = 'before'">
+        <xsl:call-template name="formal.object.heading"/>
+        <xsl:apply-templates/>
+        <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:if test="$spacing.paras != 0"><p/></xsl:if>
+        <xsl:apply-templates/>
+        <xsl:call-template name="formal.object.heading"/>
+      </xsl:otherwise>
+    </xsl:choose>
   </div>
 </xsl:template>
 
 <xsl:template name="formal.object.heading">
-  <p>
-    <xsl:call-template name="anchor"/>
+  <p class="title">
     <b>
       <xsl:apply-templates select="." mode="object.title.markup">
         <xsl:with-param name="allow-anchors" select="1"/>
 </xsl:template>
 
 <xsl:template name="semiformal.object">
+  <xsl:param name="placement" select="'before'"/>
   <xsl:choose>
     <xsl:when test="title">
-      <xsl:call-template name="formal.object"/>
+      <xsl:call-template name="formal.object">
+        <xsl:with-param name="placement" select="$placement"/>
+      </xsl:call-template>
     </xsl:when>
     <xsl:otherwise>
       <xsl:call-template name="informal.object"/>
 </xsl:template>
 
 <xsl:template match="figure|table|example">
-  <xsl:call-template name="formal.object"/>
+  <xsl:variable name="param.placement"
+                select="substring-after(normalize-space($formal.title.placement),
+                                        concat(local-name(.), ' '))"/>
+
+  <xsl:variable name="placement">
+    <xsl:choose>
+      <xsl:when test="contains($param.placement, ' ')">
+        <xsl:value-of select="substring-before($param.placement, ' ')"/>
+      </xsl:when>
+      <xsl:when test="$param.placement = ''">before</xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="$param.placement"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
+  <xsl:call-template name="formal.object">
+    <xsl:with-param name="placement" select="$placement"/>
+  </xsl:call-template>
 </xsl:template>
 
 <xsl:template match="equation">
-  <xsl:call-template name="semiformal.object"/>
+  <xsl:variable name="param.placement"
+                select="substring-after(normalize-space($formal.title.placement),
+                                        concat(local-name(.), ' '))"/>
+
+  <xsl:variable name="placement">
+    <xsl:choose>
+      <xsl:when test="contains($param.placement, ' ')">
+        <xsl:value-of select="substring-before($param.placement, ' ')"/>
+      </xsl:when>
+      <xsl:when test="$param.placement = ''">before</xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="$param.placement"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
+  <xsl:call-template name="semiformal.object">
+    <xsl:with-param name="placement" select="$placement"/>
+  </xsl:call-template>
 </xsl:template>
 
 <xsl:template match="figure/title"></xsl:template>
index 44c6d02af55f7fd0fa2994f69644fb9a597a6907..813855a2127fff049658f7085d569a838f5fe9c4 100644 (file)
@@ -36,7 +36,7 @@
 </xsl:template>
 
 <xsl:template match="itemizedlist/title">
-  <p><b><xsl:apply-templates/></b></p>
+  <p class="title"><b><xsl:apply-templates/></b></p>
 </xsl:template>
 
 <xsl:template match="itemizedlist/listitem">
 </xsl:template>
 
 <xsl:template match="orderedlist/title">
-  <p><b><xsl:apply-templates/></b></p>
+  <p class="title"><b><xsl:apply-templates/></b></p>
 </xsl:template>
 
 <xsl:template match="orderedlist/listitem">
 </xsl:template>
 
 <xsl:template match="variablelist/title">
-  <p><b><xsl:apply-templates/></b></p>
+  <p class="title"><b><xsl:apply-templates/></b></p>
 </xsl:template>
 
 <xsl:template match="listitem" mode="xref">
 <!-- ==================================================================== -->
 
 <xsl:template match="procedure">
+  <xsl:variable name="param.placement"
+                select="substring-after(normalize-space($formal.title.placement),
+                                        concat(local-name(.), ' '))"/>
+
+  <xsl:variable name="placement">
+    <xsl:choose>
+      <xsl:when test="contains($param.placement, ' ')">
+        <xsl:value-of select="substring-before($param.placement, ' ')"/>
+      </xsl:when>
+      <xsl:when test="$param.placement = ''">before</xsl:when>
+      <xsl:otherwise>
+        <xsl:value-of select="$param.placement"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
+  <xsl:variable name="preamble"
+                select="*[not(self::step or self::title)]"/>
+
   <div class="{name(.)}">
     <xsl:call-template name="anchor"/>
-    <xsl:if test="title or $formal.procedures != 0">
-      <xsl:call-template name="formal.object.heading"/>
+
+    <xsl:if test="title and $placement = 'before'">
+      <xsl:choose>
+        <xsl:when test="$formal.procedures != 0">
+          <xsl:call-template name="formal.object.heading"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:apply-templates select="title"/>
+        </xsl:otherwise>
+      </xsl:choose>
     </xsl:if>
-    <xsl:apply-templates select="*[local-name()!='step']"/>
+
+    <xsl:apply-templates select="$preamble"/>
 
     <xsl:choose>
       <xsl:when test="count(step) = 1">
         </ol>
       </xsl:otherwise>
     </xsl:choose>
+
+    <xsl:if test="title and $placement != 'before'">
+      <xsl:choose>
+        <xsl:when test="$formal.procedures != 0">
+          <xsl:call-template name="formal.object.heading"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:apply-templates select="title"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:if>
   </div>
 </xsl:template>
 
 <xsl:template match="procedure/title">
+  <p class="title">
+    <b>
+      <xsl:apply-templates/>
+    </b>
+  </p>
 </xsl:template>
 
 <xsl:template match="title" mode="procedure.title.mode">
-  <p>
+  <p class="title">
     <b>
       <xsl:apply-templates/>
     </b>
index 81a08f1bede23316ee9be183b25aaf975101d1cb..719fb0579b753f98623cb9a0d30ce3be8c1e146e 100644 (file)
@@ -36,6 +36,7 @@
 <!ENTITY emphasis.propagates.style SYSTEM "../params/emphasis.propagates.style.xml">
 <!ENTITY firstterm.only.link SYSTEM "../params/firstterm.only.link.xml">
 <!ENTITY formal.procedures SYSTEM "../params/formal.procedures.xml">
+<!ENTITY formal.title.placement SYSTEM "../params/formal.title.placement.xml">
 <!ENTITY funcsynopsis.decoration SYSTEM "../params/funcsynopsis.decoration.xml">
 <!ENTITY funcsynopsis.style SYSTEM "../params/funcsynopsis.style.xml">
 <!ENTITY function.parens SYSTEM "../params/function.parens.xml">
index 818f58078cf083dbe0b62b4c5c90e99a490aed37..9af05df075c9beb8fadc047b12fbe0c9aeff4e68 100644 (file)
@@ -216,6 +216,7 @@ to be incomplete. Don't forget to read the source, too :-)</para>
 <reference><title>Miscellaneous</title>
 &graphic.default.extension;
 &formal.procedures;
+&formal.title.placement;
 &runinhead.default.title.end.punct;
 &runinhead.title.end.punct;
 &show.comments;
@@ -352,6 +353,7 @@ around all these parameters.</para>
 <src:fragref linkend="emphasis.propagates.style.frag"/>
 <src:fragref linkend="firstterm.only.link.frag"/>
 <src:fragref linkend="formal.procedures.frag"/>
+<src:fragref linkend="formal.title.placement.frag"/>
 <src:fragref linkend="funcsynopsis.decoration.frag"/>
 <src:fragref linkend="funcsynopsis.style.frag"/>
 <src:fragref linkend="function.parens.frag"/>
diff --git a/xsl/params/formal.title.placement.xml b/xsl/params/formal.title.placement.xml
new file mode 100644 (file)
index 0000000..f6cecf5
--- /dev/null
@@ -0,0 +1,35 @@
+<refentry id="formal.title.placement">
+<refmeta>
+<refentrytitle>formal.title.placement</refentrytitle>
+<refmiscinfo role="type"></refmiscinfo>
+</refmeta>
+<refnamediv>
+<refname>formal.title.placement</refname>
+<refpurpose></refpurpose>
+</refnamediv>
+
+<refsynopsisdiv>
+<src:fragment id='formal.title.placement.frag'>
+<xsl:param name="formal.title.placement">
+figure before
+example before
+equation before
+table before
+procedure before
+</xsl:param>
+</src:fragment>
+</refsynopsisdiv>
+
+<refsect1><title>Description</title>
+
+<para>Specifies where formal object titles should occur. For each formal object
+type (<sgmltag>figure</sgmltag>,
+<sgmltag>example</sgmltag>,
+<sgmltag>equation</sgmltag>,
+<sgmltag>table</sgmltag>, and <sgmltag>procedure</sgmltag>)
+you can specify either the keyword
+<quote><literal>before</literal></quote> or
+<quote><literal>after</literal></quote>.</para>
+
+</refsect1>
+</refentry>