]> granicus.if.org Git - docbook-dsssl/commitdiff
db2man by Martijn van Beers
authorNorman Walsh <ndw@nwalsh.com>
Sat, 1 Dec 2001 19:04:28 +0000 (19:04 +0000)
committerNorman Walsh <ndw@nwalsh.com>
Sat, 1 Dec 2001 19:04:28 +0000 (19:04 +0000)
contrib/xsl/db2man/README [new file with mode: 0644]
contrib/xsl/db2man/db2man.xsl [new file with mode: 0644]
contrib/xsl/db2man/lists.xsl [new file with mode: 0644]
contrib/xsl/db2man/sect23.xsl [new file with mode: 0644]
contrib/xsl/db2man/synop.xsl [new file with mode: 0644]

diff --git a/contrib/xsl/db2man/README b/contrib/xsl/db2man/README
new file mode 100644 (file)
index 0000000..36368cd
--- /dev/null
@@ -0,0 +1,10 @@
+README for db2man by Martijn van Beers (lotr@users.sourceforge.net)
+
+I've been working on some stylesheets to convert <refentry>s to man
+format. I thought I'd submit what I have for inclusion in the
+docbook-xsl package.
+
+See also:
+
+  http://sourceforge.net/tracker/index.php?func=detail&aid=468779&group_id=21935&atid=373749
+
diff --git a/contrib/xsl/db2man/db2man.xsl b/contrib/xsl/db2man/db2man.xsl
new file mode 100644 (file)
index 0000000..b3b95e0
--- /dev/null
@@ -0,0 +1,179 @@
+<?xml version='1.0'?>
+<!-- vim:set sts=2 shiftwidth=2 syntax=sgml: -->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                version='1.0'>
+
+<xsl:include href="http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl">
+
+<xsl:include href="synop.xsl"/>
+<xsl:include href="lists.xsl"/>
+
+<xsl:output method="text"
+            encoding="ISO-8859-1"
+            indent="no"/>
+
+
+<xsl:template match="refsect2">
+  <xsl:text>
+.Sh "</xsl:text>
+  <xsl:value-of select="substring-before(title[1],' ')"/>
+  <xsl:text>"
+</xsl:text>
+  <xsl:apply-templates/>
+</xsl:template>
+<xsl:template match="refsect2/programlisting"></xsl:template>
+
+<xsl:template match="refsect2/informaltable/tgroup/tbody/row">
+  <xsl:text>.Ip "\(bu \s-1</xsl:text>
+  <xsl:value-of select="entry[1]/parameter[1]"/>
+  <xsl:text>\s0 \- </xsl:text>
+  <xsl:value-of select="normalize-space(entry[2])"/>
+  <xsl:text>"
+</xsl:text>
+</xsl:template>
+
+<xsl:template match="refsect1">
+  <xsl:text>
+.SH "</xsl:text>
+  <xsl:value-of select="translate(title[1],'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
+  <xsl:text>"
+</xsl:text>
+  <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="refsynopsisdiv">
+  <xsl:text>
+.SH "SYNOPSIS"
+</xsl:text>
+  <xsl:apply-templates/>
+</xsl:template>
+
+
+<xsl:template match="para">
+  <xsl:variable name="foo">
+    <xsl:apply-templates/>
+  </xsl:variable>
+  <xsl:text>
+.PP
+</xsl:text>
+  <xsl:value-of select="normalize-space($foo)"/>
+  <xsl:text>
+</xsl:text>
+</xsl:template>
+  
+<xsl:template match="refentry">
+  <xsl:text>."Generated by db2man.xsl. Don't modify this, modify the source.
+.de Sh \" Subsection
+.br
+.if t .Sp
+.ne 5
+.PP
+\fB\\$1\fR
+.PP
+..
+.de Sp \" Vertical space (when we can't use .PP)
+.if t .sp .5v
+.if n .sp
+..
+.de Ip \" List item
+.br
+.ie \\n(.$>=3 .ne \\$3
+.el .ne 3
+.IP "\\$1" \\$2
+..
+.TH "</xsl:text>
+  <xsl:value-of select="refnamediv/refname[1]"/>
+  <xsl:text>" </xsl:text>
+  <xsl:value-of select="refmeta/manvolnum[1]"/>
+  <xsl:text> "" "" "</xsl:text>
+  <xsl:value-of select="refentryinfo/title"/>
+  <xsl:text>"
+</xsl:text>
+  <xsl:apply-templates/>
+  <xsl:text>
+.SH AUTHOR
+</xsl:text>
+  <xsl:choose>
+    <xsl:when test="/refentry">
+      <xsl:apply-templates select="/refentry/refentryinfo/*"/>
+    </xsl:when>
+    <xsl:when test="/article">
+      <xsl:apply-templates select="/article/articleinfo/*"/>
+    </xsl:when>
+    <xsl:when test="/book">
+    </xsl:when>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="refmeta"></xsl:template>
+<xsl:template match="title"></xsl:template>
+<xsl:template match="abstract"></xsl:template>
+
+<xsl:template match="author">
+  <xsl:call-template name="person.name"/>
+  <xsl:apply-templates select="./affiliation/address/email" />
+</xsl:template>
+
+<xsl:template match="copyright">
+  <xsl:text>Copyright </xsl:text>
+  <xsl:apply-templates select="./year" />
+  <xsl:text>
+.Sp
+</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="refnamediv">
+  <xsl:text>.SH NAME
+</xsl:text>
+  <xsl:value-of select="refname"/>
+  <xsl:text> \- </xsl:text>
+  <xsl:value-of select="refpurpose"/>
+</xsl:template>
+
+<xsl:template match="refentry/refentryinfo"></xsl:template>
+
+<xsl:template match="option">
+  <xsl:text>\fB</xsl:text><xsl:apply-templates/><xsl:text>\fR</xsl:text>
+</xsl:template>
+
+<xsl:template match="replaceable">
+  <xsl:text>\fI</xsl:text><xsl:apply-templates/><xsl:text>\fR</xsl:text>
+</xsl:template>
+
+<xsl:template match="filename">
+  <xsl:text>
+.FN </xsl:text><xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="userinput">
+  <xsl:text>
+.IP
+.B </xsl:text><xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="envar">
+  <xsl:text>\fB</xsl:text><xsl:apply-templates/><xsl:text>\fR</xsl:text>
+</xsl:template>
+
+<xsl:template match="filename">
+  <xsl:text>\fI</xsl:text><xsl:apply-templates/><xsl:text>\fR</xsl:text>
+</xsl:template>
+
+<xsl:template match="ulink">
+  <xsl:apply-templates/>
+  <xsl:text>: \fI</xsl:text>
+  <xsl:value-of select="@url"/>
+  <xsl:text>\fR</xsl:text>
+</xsl:template>
+
+<xsl:template match="article">
+  <xsl:apply-templates select="refentry"/>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/contrib/xsl/db2man/lists.xsl b/contrib/xsl/db2man/lists.xsl
new file mode 100644 (file)
index 0000000..02bcfdc
--- /dev/null
@@ -0,0 +1,42 @@
+<?xml version='1.0'?>
+<!-- vim:set sts=2 shiftwidth=2 syntax=sgml: -->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                version='1.0'>
+
+<xsl:template match="varlistentry">
+  <xsl:text>
+.TP
+</xsl:text>
+<xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="varlistentry/term">
+  <xsl:apply-templates/>
+  <xsl:text>, </xsl:text>
+</xsl:template>
+
+<xsl:template match="varlistentry/term[position()=last()]" priority="2">
+  <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="itemizedlist/listitem">
+  <xsl:text>
+\(bu </xsl:text>
+  <xsl:apply-templates/>
+  <xsl:text>
+.Sp
+</xsl:text>
+</xsl:template>
+
+<xsl:template match="varlistentry/listitem/para">
+  <xsl:variable name="foo">
+    <xsl:apply-templates/>
+  </xsl:variable>
+  <xsl:text>
+</xsl:text>
+  <xsl:value-of select="normalize-space($foo)"/>
+  <xsl:text>
+</xsl:text>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/contrib/xsl/db2man/sect23.xsl b/contrib/xsl/db2man/sect23.xsl
new file mode 100644 (file)
index 0000000..03fff1b
--- /dev/null
@@ -0,0 +1,165 @@
+<?xml version='1.0'?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                version='1.0'>
+
+<xsl:template match="refsect2">
+  <xsl:text>
+.Sh "</xsl:text>
+  <xsl:value-of select="substring-before(title[1],' ')"/>
+  <xsl:text>"
+</xsl:text>
+  <xsl:apply-templates/>
+</xsl:template>
+<xsl:template match="refsect2/title"></xsl:template>
+<xsl:template match="refsect2/programlisting"></xsl:template>
+
+<xsl:template match="funcsynopsis">
+  <xsl:text>
+.BI "</xsl:text>
+  <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="funcsynopsis/funcprototype">
+  <xsl:apply-templates/>
+  <xsl:text> );
+.br
+</xsl:text>
+</xsl:template>
+
+<xsl:template match="funcsynopsis/funcprototype/funcdef">
+  <xsl:apply-templates/>
+  <xsl:value-of select="function"/>
+  <xsl:text> (</xsl:text>
+</xsl:template>
+<xsl:template match="funcsynopsis/funcprototype/funcdef/function"></xsl:template>
+
+<xsl:template match="funcsynopsis/funcprototype/paramdef">
+  <xsl:apply-templates/>
+  <xsl:text>" </xsl:text>
+  <xsl:value-of select="parameter"/>
+  <xsl:choose>
+  <xsl:when test="following-sibling::paramdef">
+    <xsl:text> ", </xsl:text>
+  </xsl:when>
+  </xsl:choose>
+</xsl:template>
+<xsl:template match="funcsynopsis/funcprototype/paramdef/parameter"></xsl:template>
+
+<xsl:template match="refsect2/informaltable/tgroup/tbody/row">
+  <xsl:text>.Ip "\(bu \s-1</xsl:text>
+  <xsl:value-of select="entry[1]/parameter[1]"/>
+  <xsl:text>\s0 \- </xsl:text>
+  <xsl:value-of select="normalize-space(entry[2])"/>
+  <xsl:text>"
+</xsl:text>
+</xsl:template>
+
+<xsl:template match="refsect1">
+  <xsl:text>
+.SH "</xsl:text>
+  <xsl:value-of select="translate(title[1],'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
+  <xsl:text>"
+</xsl:text>
+  <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="refsynopsisdiv">
+  <xsl:text>
+.SH "</xsl:text>
+  <xsl:value-of select="translate(title[1],'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
+  <xsl:text>"
+</xsl:text>
+  <xsl:apply-templates/>
+</xsl:template>
+<xsl:template match="refsynopsisdiv/title"></xsl:template>
+
+<xsl:template match="refsect1/title"></xsl:template>
+
+<xsl:template match="para">
+     <xsl:text>.PP
+</xsl:text>
+     <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="*"><xsl:apply-templates/></xsl:template>
+
+<xsl:template match="refentry">
+  <xsl:text>." DO NOT MODIFY THIS FILE!
+.de Sh \" Subsection
+.br
+.if t .Sp
+.ne 5
+.PP
+\fB\\$1\fR
+.PP
+..
+.de Sp \" Vertical space (when we can't use .PP)
+.if t .sp .5v
+.if n .sp
+..
+.de Ip \" List item
+.br
+.ie \\n(.$>=3 .ne \\$3
+.el .ne 3
+.IP "\\$1" \\$2
+..
+.TH "</xsl:text>
+  <xsl:value-of select="refmeta/refentrytitle[1]"/>
+  <xsl:text>" </xsl:text>
+  <xsl:value-of select="refmeta/manvolnum[1]"/>
+  <xsl:text> "</xsl:text>
+  <xsl:value-of select="@revision"/>
+  <xsl:text>"
+</xsl:text>
+  <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="refmeta"></xsl:template>
+
+<xsl:template match="refnamediv">
+  <xsl:text>.SH NAME
+</xsl:text>
+  <xsl:value-of select="refname"/>
+  <xsl:text> \- </xsl:text>
+  <xsl:value-of select="refpurpose"/>
+</xsl:template>
+
+<xsl:template match="refentry/refentrytitle"></xsl:template>
+<xsl:template match="article/articleinfo/*"></xsl:template>
+
+<xsl:template match="term/option">
+  <xsl:text>\fB</xsl:text><xsl:apply-templates/><xsl:text>\fR</xsl:text>
+</xsl:template>
+
+<xsl:template match="varlistentry">
+  <xsl:text>
+.TP
+</xsl:text>
+<xsl:apply-templates select="./term"/>
+<xsl:apply-templates select="./listitem"/>
+</xsl:template>
+
+<xsl:template match="varlistentry/listitem/para">
+  <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="filename">
+  <xsl:text>
+.FN </xsl:text><xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="userinput">
+  <xsl:text>
+.IP
+.B </xsl:text><xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="envar">
+  <xsl:text>\fB</xsl:text><xsl:apply-templates/><xsl:text>\fR</xsl:text>
+</xsl:template>
+
+<xsl:template match="filename">
+  <xsl:text>\fI</xsl:text><xsl:apply-templates/><xsl:text>\fR</xsl:text>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/contrib/xsl/db2man/synop.xsl b/contrib/xsl/db2man/synop.xsl
new file mode 100644 (file)
index 0000000..3781836
--- /dev/null
@@ -0,0 +1,81 @@
+<?xml version='1.0'?>
+<!-- vim:set sts=2 shiftwidth=2 syntax=sgml: -->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                version='1.0'>
+
+<xsl:template match="group|arg">
+  <xsl:variable name="choice" select="@choice"/>
+  <xsl:variable name="rep" select="@rep"/>
+  <xsl:variable name="sepchar">
+    <xsl:choose>
+      <xsl:when test="ancestor-or-self::*/@sepchar">
+        <xsl:value-of select="ancestor-or-self::*/@sepchar"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:text> </xsl:text>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+  <xsl:if test="position()>1"><xsl:value-of select="$sepchar"/></xsl:if>
+  <xsl:choose>
+    <xsl:when test="$choice='plain'">
+      <xsl:value-of select="$arg.choice.plain.open.str"/>
+    </xsl:when>
+    <xsl:when test="$choice='req'">
+      <xsl:value-of select="$arg.choice.req.open.str"/>
+    </xsl:when>
+    <xsl:when test="$choice='opt'">
+      <xsl:value-of select="$arg.choice.opt.open.str"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:value-of select="$arg.choice.def.open.str"/>
+    </xsl:otherwise>
+  </xsl:choose>
+  <xsl:apply-templates/>
+  <xsl:choose>
+    <xsl:when test="$rep='repeat'">
+      <xsl:value-of select="$arg.rep.repeat.str"/>
+    </xsl:when>
+    <xsl:when test="$rep='norepeat'">
+      <xsl:value-of select="$arg.rep.norepeat.str"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:value-of select="$arg.rep.def.str"/>
+    </xsl:otherwise>
+  </xsl:choose>
+  <xsl:choose>
+    <xsl:when test="$choice='plain'">
+      <xsl:value-of select="$arg.choice.plain.close.str"/>
+    </xsl:when>
+    <xsl:when test="$choice='req'">
+      <xsl:value-of select="$arg.choice.req.close.str"/>
+    </xsl:when>
+    <xsl:when test="$choice='opt'">
+      <xsl:value-of select="$arg.choice.opt.close.str"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:value-of select="$arg.choice.def.close.str"/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="group/arg">
+  <xsl:if test="position()>1"><xsl:value-of select="$arg.or.sep"/></xsl:if>
+  <xsl:text>\fB</xsl:text>
+  <xsl:apply-templates/>
+  <xsl:text>\fR</xsl:text>
+</xsl:template>
+
+<xsl:template match="command">
+  <xsl:text>\fB</xsl:text>
+  <xsl:apply-templates/>
+  <xsl:text>\fR</xsl:text>
+</xsl:template>
+
+<xsl:template match="arg/replaceable">
+  <xsl:text> \fI</xsl:text>
+  <xsl:apply-templates/>
+  <xsl:text>\fR </xsl:text>
+</xsl:template>
+
+</xsl:stylesheet>