1<?xml version='1.0'?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                xmlns:exsl="http://exslt.org/common"
4                version='1.0'
5                exclude-result-prefixes="exsl">
6
7<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"/>
8<xsl:import href="stylesheet-common.xsl" />
9
10
11<!-- Parameters -->
12
13<xsl:param name="man.authors.section.enabled">0</xsl:param>
14<xsl:param name="man.copyright.section.enabled">0</xsl:param>
15<xsl:param name="man.output.base.dir"></xsl:param>
16<xsl:param name="man.output.in.separate.dir" select="1"></xsl:param>
17<xsl:param name="refentry.meta.get.quietly" select="0"></xsl:param>
18<xsl:param name="man.th.title.max.length">32</xsl:param> <!-- enough room for "CREATE TEXT SEARCH CONFIGURATION" -->
19<xsl:param name="man.th.extra3.max.length">40</xsl:param> <!-- enough room for "PostgreSQL X.Ydevel Documentation" -->
20<xsl:param name="refentry.xref.manvolnum" select="1"/> <!-- overridden from stylesheet-common.xsl -->
21
22<!-- Fixup for apostrophe groff output.  See the following references:
23     <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=457839>
24     <https://sourceforge.net/tracker/?func=detail&aid=2412738&group_id=21935&atid=373747>
25 -->
26<xsl:param name="man.string.subst.map.local.post">
27  <substitution oldstring="\'" newstring="\(aq"></substitution>
28</xsl:param>
29
30
31<!-- Custom templates -->
32
33<!-- Improve output of email element.  See also
34     <https://sourceforge.net/tracker/?func=detail&aid=3524417&group_id=21935&atid=373747>
35 -->
36<xsl:template match="email">
37  <xsl:text>&lt;</xsl:text>
38  <xsl:apply-templates/>
39  <xsl:text>&gt;</xsl:text>
40</xsl:template>
41
42
43<xsl:template match="refentry" mode="xref-to">
44  <xsl:param name="referrer"/>
45  <xsl:param name="xrefstyle"/>
46
47  <xsl:choose>
48    <!-- If the refname contains a space, we construct a reference
49         like CREATE DATABASE (CREATE_DATABASE(7)), so the reader
50         knows both the command name being referred to and the name of
51         the man page to read about it. -->
52    <xsl:when test="contains(refnamediv/refname[1],' ')">
53      <xsl:variable name="mangled.title">
54        <xsl:value-of select="translate(refnamediv/refname[1],' ','_')"/>
55      </xsl:variable>
56      <xsl:apply-templates select="refnamediv/refname[1]"/>
57      <xsl:text> (</xsl:text>
58      <xsl:call-template name="bold">
59        <xsl:with-param name="node" select="exsl:node-set($mangled.title)"/>
60        <xsl:with-param name="context" select="."/>
61      </xsl:call-template>
62      <xsl:apply-templates select="refmeta/manvolnum"/>
63      <xsl:text>)</xsl:text>
64    </xsl:when>
65
66    <!-- This is the original case, except that boldness has been
67         added, per the convention mentioned in man-pages(7). -->
68    <xsl:otherwise>
69      <xsl:choose>
70        <xsl:when test="refmeta/refentrytitle">
71          <xsl:call-template name="bold">
72            <xsl:with-param name="node" select="refmeta/refentrytitle"/>
73            <xsl:with-param name="context" select="."/>
74          </xsl:call-template>
75        </xsl:when>
76        <xsl:otherwise>
77          <xsl:call-template name="bold">
78            <xsl:with-param name="node" select="refnamediv/refname[1]"/>
79            <xsl:with-param name="context" select="."/>
80          </xsl:call-template>
81        </xsl:otherwise>
82      </xsl:choose>
83      <xsl:apply-templates select="refmeta/manvolnum"/>
84    </xsl:otherwise>
85  </xsl:choose>
86
87</xsl:template>
88
89
90<!-- For refentries we don't man to generate a man page for, leave out
91     manvolnum, let it default to 0, and skip writing out man files
92     with section 0. -->
93
94<!-- overridden from common/refentry.xsl -->
95<xsl:template name="get.refentry.section">
96  <xsl:choose>
97    <xsl:when test="refmeta/manvolnum">
98      <xsl:value-of select="refmeta/manvolnum"/>
99    </xsl:when>
100    <xsl:otherwise>
101      <xsl:text>0</xsl:text>
102    </xsl:otherwise>
103  </xsl:choose>
104</xsl:template>
105
106<!-- overridden from manpages/other.xsl -->
107  <xsl:template name="write.man.file">
108    <xsl:param name="name"/>
109    <xsl:param name="section"/>
110    <xsl:param name="lang"/>
111    <xsl:param name="content"/>
112    <xsl:param name="filename">
113      <xsl:call-template name="make.adjusted.man.filename">
114        <xsl:with-param name="name" select="$name"/>
115        <xsl:with-param name="section" select="$section"/>
116        <xsl:with-param name="lang" select="$lang"/>
117      </xsl:call-template>
118    </xsl:param>
119    <xsl:if test="$section != 0">
120    <xsl:call-template name="write.text.chunk">
121      <xsl:with-param name="filename" select="$filename"/>
122      <xsl:with-param name="suppress-context-node-name" select="1"/>
123      <xsl:with-param name="quiet" select="$man.output.quietly"/>
124      <xsl:with-param
125          name="message-prolog"
126          >Note: </xsl:with-param>
127      <xsl:with-param name="encoding" select="$man.output.encoding"/>
128      <xsl:with-param name="content" select="$content"/>
129    </xsl:call-template>
130    </xsl:if>
131  </xsl:template>
132
133
134<!-- Overridden template as workaround for this problem:
135     <https://sourceforge.net/tracker/?func=detail&aid=2831602&group_id=21935&atid=373747>
136-->
137  <xsl:template name="write.stubs">
138    <xsl:param name="first.refname"/>
139    <xsl:param name="section"/>
140    <xsl:param name="lang"/>
141    <xsl:for-each select="refnamediv/refname">
142      <xsl:if test=". != $first.refname">
143        <xsl:call-template name="write.text.chunk">
144          <xsl:with-param name="filename">
145            <xsl:call-template name="make.adjusted.man.filename">
146              <xsl:with-param name="name" select="."/>
147              <xsl:with-param name="section" select="$section"/>
148              <xsl:with-param name="lang" select="$lang"/>
149            </xsl:call-template>
150          </xsl:with-param>
151          <xsl:with-param name="quiet" select="$man.output.quietly"/>
152          <xsl:with-param name="suppress-context-node-name" select="1"/>
153          <xsl:with-param name="message-prolog">Note: </xsl:with-param>
154          <xsl:with-param name="message-epilog"> (soelim stub)</xsl:with-param>
155          <xsl:with-param name="content">
156            <xsl:choose>
157              <xsl:when test="$man.output.in.separate.dir = 0">
158                <xsl:value-of select="concat('.so man', $section, '/')"/>
159              </xsl:when>
160              <xsl:otherwise>
161                <xsl:value-of select="'.so '"/> <!-- added case -->
162              </xsl:otherwise>
163            </xsl:choose>
164            <xsl:call-template name="make.adjusted.man.filename">
165              <xsl:with-param name="name" select="$first.refname"/>
166              <xsl:with-param name="section" select="$section"/>
167            </xsl:call-template>
168            <xsl:text>&#10;</xsl:text>
169          </xsl:with-param>
170        </xsl:call-template>
171      </xsl:if>
172    </xsl:for-each>
173  </xsl:template>
174
175
176  <!-- https://sourceforge.net/tracker/?func=detail&aid=3545150&group_id=21935&atid=373747 -->
177  <xsl:template match="step/title">
178    <xsl:apply-templates/>
179    <xsl:text>: </xsl:text>
180  </xsl:template>
181
182
183  <!-- http://sourceforge.net/p/docbook/bugs/1340/ -->
184  <xsl:template match="indexterm"/>
185
186
187<!-- Gentext customization -->
188
189<!-- see http://www.sagehill.net/docbookxsl/CustomGentext.html -->
190<xsl:param name="local.l10n.xml" select="document('')"/>
191<l:i18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">
192  <l:l10n language="en">
193    <!-- Use ISO 8601 date format. -->
194    <l:context name="datetime">
195      <l:template name="format" text="Y-m-d"/>
196    </l:context>
197
198    <!-- Slight rephrasing to indicate that missing sections are found
199         in the documentation. -->
200    <l:context name="xref-number-and-title">
201      <l:template name="chapter" text="Chapter %n, %t, in the documentation"/>
202      <l:template name="sect1" text="Section %n, “%t”, in the documentation"/>
203      <l:template name="sect2" text="Section %n, “%t”, in the documentation"/>
204      <l:template name="sect3" text="Section %n, “%t”, in the documentation"/>
205      <l:template name="sect4" text="Section %n, “%t”, in the documentation"/>
206      <l:template name="sect5" text="Section %n, “%t”, in the documentation"/>
207    </l:context>
208  </l:l10n>
209</l:i18n>
210
211</xsl:stylesheet>
212