]> granicus.if.org Git - docbook-dsssl/commitdiff
Added support for refsect3 and formalpara processing (closes
authorMichael Smith <xmldoc@users.sourceforge.net>
Sat, 28 May 2005 18:01:35 +0000 (18:01 +0000)
committerMichael Smith <xmldoc@users.sourceforge.net>
Sat, 28 May 2005 18:01:35 +0000 (18:01 +0000)
#1210478 and #1210479).

Also did some further templates re-organizing, including to the
logic for gathering and processing metadata.

xsl/manpages/block.xsl
xsl/manpages/docbook.xsl
xsl/manpages/general.xsl
xsl/manpages/refentry.xsl [new file with mode: 0644]

index 430771f3f4099d112e7daf273676ba8934a435aa..053522decc0e20199ad47f3d7a4183863464a279 100644 (file)
 
 <!-- ==================================================================== -->
 
-<xsl:template match="refsection|refsect1">
-  <xsl:choose>
-    <xsl:when test="ancestor::refsection">
-      <xsl:text>.SS "</xsl:text>
-      <xsl:value-of select="title[1]"/>
-    </xsl:when>
-    <xsl:otherwise>
-      <xsl:text>.SH "</xsl:text>
-      <xsl:value-of
-          select="translate(title[1],
-                  'abcdefghijklmnopqrstuvwxyz',
-                  'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
-    </xsl:otherwise>
-  </xsl:choose>
-  <xsl:text>"&#10;</xsl:text>
-  <xsl:apply-templates/>
-</xsl:template>
-
-<xsl:template match="refsect2">
-  <xsl:text>.SS "</xsl:text>
-  <xsl:value-of select="title[1]"/>
-  <xsl:text>"&#10;</xsl:text>
-  <xsl:apply-templates/>
-</xsl:template>
-
-<xsl:template match="refsynopsisdiv">
-  <xsl:text>.SH "</xsl:text>
-  <xsl:call-template name="string.upper">
-    <xsl:with-param name="string">
-      <xsl:call-template name="gentext">
-        <xsl:with-param name="key" select="'RefSynopsisDiv'"/>
-      </xsl:call-template>
-    </xsl:with-param>
-  </xsl:call-template>
-  <xsl:text>"&#10;</xsl:text>
+<xsl:template match="caution|important|note|tip|warning">
+  <xsl:call-template name="nested-section-title"/>
+  <xsl:text>&#10;</xsl:text>
   <xsl:apply-templates/>
-</xsl:template>
+</xsl:template> 
 
-<xsl:template match="refnamediv">
-  <xsl:text>.SH "</xsl:text>
-  <xsl:call-template name="string.upper">
-    <xsl:with-param name="string">
-      <xsl:call-template name="gentext">
-        <xsl:with-param name="key" select="'RefName'"/>
-      </xsl:call-template>
-    </xsl:with-param>
-  </xsl:call-template>
-  <xsl:text>"&#10;</xsl:text>
-  <xsl:for-each select="refname">
-    <xsl:if test="position()>1">
-      <xsl:text>, </xsl:text>
-    </xsl:if>
-    <xsl:value-of select="."/>
-  </xsl:for-each>
-  <xsl:text> \- </xsl:text>
-  <xsl:value-of select="normalize-space (refpurpose)"/>
+<xsl:template match="formalpara">
+  <xsl:call-template name="nested-section-title"/>
   <xsl:text>&#10;</xsl:text>
+  <xsl:text>.RS 3&#10;</xsl:text>
+  <xsl:apply-templates/>
+  <xsl:text>.RE&#10;</xsl:text>
 </xsl:template>
 
-<xsl:template match="refentry/refentryinfo"></xsl:template>
-
-<xsl:template match="caution|important|note|tip|warning">
-  <xsl:text>.RS&#10;.Sh "</xsl:text>
-    <xsl:apply-templates select="." mode="object.title.markup.textonly"/>
-    <xsl:text>"&#10;</xsl:text>
-    <xsl:apply-templates/>
-    <xsl:text>.RE&#10;</xsl:text>
-</xsl:template> 
-
 <xsl:template match="para">
   <xsl:text>.PP&#10;</xsl:text>
   <xsl:call-template name="mixed-block"/>
   <!-- Yes, address and synopsis are verbatim environments. -->
 
   <xsl:choose>
-    <!-- Check to see if this vertbatim item is within a parent element that -->
+    <!-- Check to see if this verbatim item is within a parent element that -->
     <!-- allows mixed content. -->
     
     <!-- If it is within a mixed-content parent, then a line break is -->
index 711f9a74515f7ceb5f7ab73dba2a47910bd2aaa2..5d010ced79b70550ef23d0a921823a8c2becf78a 100644 (file)
@@ -17,7 +17,9 @@
 <!-- ==================================================================== -->
 
 <xsl:import href="../html/docbook.xsl"/>
+<xsl:include href="param.xsl"/>
 <xsl:include href="general.xsl"/>
+<xsl:include href="refentry.xsl"/>
 <xsl:include href="block.xsl"/>
 <xsl:include href="inline.xsl"/>
 <xsl:include href="synop.xsl"/>
 
 <!-- ============================================================== -->
 
-<!--                The real fun starts here -->
-
-<!-- ============================================================== -->
-
 <xsl:template match="refentry">
 
-  <xsl:variable name="get.metainfo">
-    <xsl:call-template name="get.metainfo" />
+  <xsl:variable name="get.metadata">
+    <xsl:call-template name="get.metadata"/>
   </xsl:variable>
-  
-  <xsl:variable name="metainfo" select="exsl:node-set($get.metainfo)"/>
+
+  <xsl:variable name="metadata" select="exsl:node-set($get.metadata)"/>
 
   <xsl:call-template name="write.text.chunk">
-    <xsl:with-param name="filename" select="$metainfo/filename"/>
+    <xsl:with-param name="filename" select="$metadata/filename"/>
     <xsl:with-param name="content">
 
-      <!-- page header (commented-out stuff at top of roff source) -->
+      <!-- page header (commented-out at top of roff source) -->
       <xsl:call-template name="page.header"/>
       
       <!-- .TH line (sets title stuff and begin and end)-->
       <xsl:call-template name="TH.title.section">
-        <xsl:with-param name="reftitle" select="$metainfo/reftitle"/>
-        <xsl:with-param name="section" select="$metainfo/section"/>
-        <xsl:with-param name="date" select="$metainfo/date"/>
-        <xsl:with-param name="productname" select="$metainfo/productname"/>
-        <xsl:with-param name="title" select="$metainfo/title"/>
+        <xsl:with-param name="reftitle" select="$metadata/reftitle"/>
+        <xsl:with-param name="section" select="$metadata/section"/>
+        <xsl:with-param name="date" select="$metadata/date"/>
+        <xsl:with-param name="productname" select="$metadata/productname"/>
+        <xsl:with-param name="extra3" select="$metadata/extra3"/>
       </xsl:call-template>
       
       <!-- main body of man page -->
   <!-- Now generate stub include pages for every page documented in
        this refentry (except the page itself) -->
   <xsl:for-each select="refnamediv/refname">
-    <xsl:if test=". != $metainfo/name">
+    <xsl:if test=". != $metadata/name">
       <xsl:call-template name="write.text.chunk">
         <xsl:with-param name="filename"
                         select="concat(normalize-space(.), '.',
-                                $metainfo/section)"/>
+                                $metadata/section)"/>
         <xsl:with-param
             name="content"
             select="concat('.so man',
-                    $metainfo/section,
+                    $metadata/section,
                     '/',
-                    $metainfo/name,
+                    $metadata/name,
                     '.',
-                    $metainfo/section,
+                    $metadata/section,
                     '&#10;')"/>
       </xsl:call-template>
     </xsl:if>
 
 <!-- ============================================================== -->
 
-<!--        Named templates for each "part" of output page: -->
+<!--        Named templates for each part of output page -->
 
 <!-- ============================================================== -->
 
 <!-- ============================================================== -->
 
 <xsl:template name="page.header">
-      <xsl:text>.\"Generated by db2man.xsl. Don't modify this, modify the source.
-.\"
-. \"---------------------------------------------------
-.de Sh \" - a second-level section (a DocBook refsect2)
-.br
-.if t .Sp
-.ne 5
-\fB\\$1\fR
-.PP
-..\"---------------------------------------------------
-.de Sp \" - vertical space (when we can't use .PP)
-.if t .sp .5v
-.if n .sp
-..\"---------------------------------------------------
-.de Ip \" - a list item
-.br
-.ie \\n(.$>=3 .ne \\$3
-.el .ne 3
-.IP "\\$1" \\$2
-..\"---------------------------------------------------
-.\"</xsl:text>
-<xsl:text>&#10;</xsl:text>
+  <xsl:text>.\"Generated by db2man.xsl. Don't modify this, modify the source.&#10;</xsl:text>
 </xsl:template>
 
 <xsl:template name="TH.title.section">
-  <xsl:param name="title"/>
   <xsl:param name="reftitle"/>
   <xsl:param name="section"/>
   <xsl:param name="date"/>
   <xsl:param name="productname"/>
+  <xsl:param name="extra3"/>
 
   <xsl:text>.\" "TITLE" "SECTION NUMBER" "DATE" "PRODUCT" "GROUP TITLE"</xsl:text>
   <xsl:text>&#10;</xsl:text>
       <xsl:text>" "</xsl:text>
       <xsl:value-of select="normalize-space($productname)"/>
       <xsl:text>" "</xsl:text>
-      <xsl:value-of select="$title"/>
+      <xsl:value-of select="normalize-space($extra3)"/>
       <xsl:text>"&#10;</xsl:text>
 </xsl:template>
 
 
 <!-- ============================================================== -->
 
-<!--        Named template for getting metainfo from source  -->
+<!--        Named template for getting metadata  -->
 
 <!-- ============================================================== -->
 
-<xsl:template name="get.metainfo">
+<xsl:template name="get.metadata">
+
+  <xsl:variable name="name" select="refnamediv/refname[1]"/>
 
   <xsl:variable name="section">
     <xsl:choose>
     <xsl:value-of select="$section"/>
   </section>
 
-  <xsl:variable name="name" select="refnamediv/refname[1]"/>
-
-  <name>
-    <xsl:value-of select="$name"/>
-  </name>
-
-  <!-- standard man page width is 64 chars; 6 chars needed for the two
-       (x) volume numbers, and 2 spaces, leaves 56 -->
-  <xsl:variable name="twidth" select="(56 - string-length(refmeta/refentrytitle)) div 2"/>
-
-  <reftitle>
-    <xsl:value-of select="substring(refmeta/refentrytitle, 1, $twidth)"/>
-  </reftitle>
+  <filename>
+    <xsl:call-template name="replace-string">
+      <!-- replace spaces in source filename with underscores in output filename -->
+      <xsl:with-param name="content"
+                      select="concat(normalize-space ($name), '.', $section)"/>
+      <xsl:with-param name="replace" select="' '"/>
+      <xsl:with-param name="with" select="'_'"/>
+    </xsl:call-template>
+  </filename>
 
-  <title>
+  <xsl:variable name="reftitle">
     <xsl:choose>
-      <xsl:when test="refentryinfo/title">
-        <xsl:value-of select="refentryinfo/title"/>
-      </xsl:when>
-      <xsl:when test="../referenceinfo/title">
-        <xsl:value-of select="../referenceinfo/title"/>
+      <xsl:when test="refmeta/refentrytitle">
+        <xsl:copy>
+          <xsl:apply-templates select="refmeta/refentrytitle/node()"/>
+        </xsl:copy>
       </xsl:when>
+      <xsl:otherwise>
+        <xsl:copy-of select="$name"/>
+      </xsl:otherwise>
     </xsl:choose>
-  </title>
+  </xsl:variable>
+
+  <reftitle>
+    <xsl:value-of select="substring($reftitle, 1, 20)"/>
+  </reftitle>
 
   <date>
     <xsl:choose>
-      <xsl:when test="refentryinfo/date">
-        <xsl:value-of select="refentryinfo/date"/>
+      <xsl:when test="info/date">
+        <xsl:copy>
+          <xsl:apply-templates select="info/date/node()"/>
+        </xsl:copy>
       </xsl:when>
-      <xsl:when test="../referenceinfo/date">
-        <xsl:value-of select="../referenceinfo/date"/>
+      <xsl:when test="refentryinfo/date">
+        <xsl:copy>
+          <xsl:apply-templates select="refentryinfo/date/node()"/>
+        </xsl:copy>
       </xsl:when>
+      <xsl:otherwise>
+        <xsl:copy>
+          <xsl:apply-templates select="../referenceinfo/date/node()"/>
+        </xsl:copy>
+      </xsl:otherwise>
     </xsl:choose>
   </date>
-
+  
   <productname>
     <xsl:choose>
-      <xsl:when test="refentryinfo/productname">
-        <xsl:value-of select="refentryinfo/productname"/>
+      <xsl:when test="info/productname">
+        <xsl:apply-templates select="info/productname/node()"/>
       </xsl:when>
-      <xsl:when test="../referenceinfo/productname">
-        <xsl:value-of select="../referenceinfo/productname"/>
+      <xsl:when test="refentryinfo/productname">
+        <xsl:apply-templates select="refentryinfo/productnam/node()"/>
       </xsl:when>
+      <xsl:otherwise>
+        <xsl:apply-templates select="../referenceinfo/productname/node()"/>
+      </xsl:otherwise>
     </xsl:choose>
   </productname>
-
-  <filename>
-    <xsl:call-template name="replace-string">
-      <!-- replace spaces in source filename with underscores in output filename -->
-      <xsl:with-param name="content"
-                      select="concat(normalize-space ($name), '.', $section)"/>
-      <xsl:with-param name="replace" select="' '"/>
-      <xsl:with-param name="with" select="'_'"/>
-    </xsl:call-template>
-  </filename>
+  
+  <extra3></extra3>
 
 </xsl:template>
 
   </xsl:if>
 </xsl:template>
 
-<xsl:template match="copyright">
-  <xsl:text>Copyright \(co  </xsl:text>
-  <xsl:apply-templates select="./year" />
-  <xsl:text>.Sp&#10;</xsl:text>
-</xsl:template>
-
 <xsl:template match="email">
   <xsl:text>&lt;</xsl:text>
   <xsl:apply-templates/>
   <xsl:text>&gt;</xsl:text>
 </xsl:template>
 
+<xsl:template match="copyright">
+  <xsl:text>Copyright \(co  </xsl:text>
+  <xsl:apply-templates select="./year" />
+  <xsl:text>.Sp&#10;</xsl:text>
+</xsl:template>
+
 </xsl:stylesheet>
index b98b743ef05475fd4e2fcba63962df5cb8ade509..23185f1cc6bb1afd28fb34a4d51edbc5fcd218a8 100644 (file)
     </xsl:for-each>
   </xsl:template>
 
+
+  <xsl:template name="nested-section-title">
+    <xsl:text>.sp
+.it 1 an-trap
+.nr an-no-space-flag 1
+.nr an-break-flag 1
+.br</xsl:text>
+    <xsl:text>&#10;</xsl:text>
+    <xsl:call-template name="string.upper">
+      <xsl:with-param name="string">
+        <xsl:choose>
+          <xsl:when test="title">
+            <xsl:value-of select="normalize-space(title[1])"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:apply-templates select="." mode="object.title.markup.textonly"/>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:with-param>
+    </xsl:call-template>
+  </xsl:template>
+  
+
+
   <!-- jump through a few hoops to deal with mixed-content blocks, so that -->
   <!-- we don't end up munging verbatim environments or lists and so that we -->
   <!-- don't gobble up whitespace when we shouldn't -->
diff --git a/xsl/manpages/refentry.xsl b/xsl/manpages/refentry.xsl
new file mode 100644 (file)
index 0000000..1fa73dd
--- /dev/null
@@ -0,0 +1,84 @@
+<?xml version='1.0'?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                version='1.0'>
+
+<!-- ********************************************************************
+     $Id$
+     ********************************************************************
+
+     This file is part of the XSL DocBook Stylesheet distribution.
+     See ../README or http://docbook.sf.net/release/xsl/current/ for
+     copyright and other information.
+
+     ******************************************************************** -->
+
+<!-- ==================================================================== -->
+
+  <xsl:template match="refnamediv">
+    <xsl:text>.SH "</xsl:text>
+    <xsl:call-template name="string.upper">
+      <xsl:with-param name="string">
+        <xsl:call-template name="gentext">
+          <xsl:with-param name="key" select="'RefName'"/>
+        </xsl:call-template>
+      </xsl:with-param>
+    </xsl:call-template>
+    <xsl:text>"&#10;</xsl:text>
+    <xsl:for-each select="refname">
+      <xsl:if test="position()>1">
+        <xsl:text>, </xsl:text>
+      </xsl:if>
+      <xsl:value-of select="."/>
+    </xsl:for-each>
+    <xsl:text> \- </xsl:text>
+    <xsl:value-of select="normalize-space (refpurpose)"/>
+    <xsl:text>&#10;</xsl:text>
+  </xsl:template>
+
+  <xsl:template match="refsynopsisdiv">
+    <xsl:text>.SH "</xsl:text>
+    <xsl:call-template name="string.upper">
+      <xsl:with-param name="string">
+        <xsl:call-template name="gentext">
+          <xsl:with-param name="key" select="'RefSynopsisDiv'"/>
+        </xsl:call-template>
+      </xsl:with-param>
+    </xsl:call-template>
+    <xsl:text>"&#10;</xsl:text>
+    <xsl:apply-templates/>
+  </xsl:template>
+
+  <xsl:template match="refsection|refsect1">
+    <xsl:choose>
+      <xsl:when test="ancestor::refsection">
+        <xsl:text>.SS "</xsl:text>
+        <xsl:value-of select="title[1]"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:text>.SH "</xsl:text>
+        <xsl:value-of
+            select="translate(title[1],
+                    'abcdefghijklmnopqrstuvwxyz',
+                    'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
+      </xsl:otherwise>
+    </xsl:choose>
+    <xsl:text>"&#10;</xsl:text>
+    <xsl:apply-templates/>
+  </xsl:template>
+
+  <xsl:template match="refsect2">
+    <xsl:text>.SS "</xsl:text>
+    <xsl:value-of select="title[1]"/>
+    <xsl:text>"&#10;</xsl:text>
+    <xsl:apply-templates/>
+  </xsl:template>
+
+  <xsl:template match="refsect3">
+    <xsl:call-template name="nested-section-title"/>
+    <xsl:text>&#10;</xsl:text>
+    <xsl:text>.RS 3&#10;</xsl:text>
+    <xsl:apply-templates/>
+    <xsl:text>.RE&#10;</xsl:text>
+  </xsl:template>
+
+</xsl:stylesheet>