Merge from Subversion r50.
[nivanova/samba-autobuild/.git] / docs / docbook / smbdotconf / man.xsl
1 <?xml version='1.0'?>
2 <!-- vim:set sts=2 shiftwidth=2 syntax=xml: -->
3 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4                 version='1.0'>
5
6 <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"/>
7
8 <xsl:param name="chunk.section.depth" select="0"/>
9 <xsl:param name="chunk.first.sections" select="1"/>
10 <xsl:param name="use.id.as.filename" select="1"/>
11 <xsl:param name="base.dir" select="'../../manpages/'"/>
12
13 <!-- 
14     Our ulink stylesheet omits @url part if content was specified
15 -->
16 <xsl:template match="ulink">
17   <xsl:variable name="content">
18     <xsl:apply-templates/>
19   </xsl:variable>
20   <xsl:if test="$content = ''">
21     <xsl:text>: </xsl:text>
22   </xsl:if>
23   <xsl:if test="$content != ''">
24     <xsl:value-of select="$content" />
25   </xsl:if>
26   <xsl:if test="$content = ''">
27     <xsl:apply-templates mode="italic" select="@url" />
28   </xsl:if>
29 </xsl:template>
30
31 <xsl:template match="refentry">
32
33   <xsl:variable name="section" select="refmeta/manvolnum"/>
34   <xsl:variable name="name" select="refnamediv/refname[1]"/>
35   <xsl:variable name="base.dir" select="$base.dir"/>
36   <!-- standard man page width is 64 chars; 6 chars needed for the two
37        (x) volume numbers, and 2 spaces, leaves 56 -->
38   <xsl:variable name="twidth" select="(74 - string-length(refmeta/refentrytitle)) div 2"/>
39
40   <xsl:variable name="reftitle" 
41                 select="substring(refmeta/refentrytitle, 1, $twidth)"/>
42
43   <xsl:variable name="title">
44     <xsl:choose>
45       <xsl:when test="refentryinfo/title">
46         <xsl:value-of select="refentryinfo/title"/>
47       </xsl:when>
48       <xsl:when test="../referenceinfo/title">
49         <xsl:value-of select="../referenceinfo/title"/>
50       </xsl:when>
51     </xsl:choose>
52   </xsl:variable>
53
54   <xsl:variable name="date">
55     <xsl:choose>
56       <xsl:when test="refentryinfo/date">
57         <xsl:value-of select="refentryinfo/date"/>
58       </xsl:when>
59       <xsl:when test="../referenceinfo/date">
60         <xsl:value-of select="../referenceinfo/date"/>
61       </xsl:when>
62     </xsl:choose>
63   </xsl:variable>
64
65   <xsl:variable name="productname">
66     <xsl:choose>
67       <xsl:when test="refentryinfo/productname">
68         <xsl:value-of select="refentryinfo/productname"/>
69       </xsl:when>
70       <xsl:when test="../referenceinfo/productname">
71         <xsl:value-of select="../referenceinfo/productname"/>
72       </xsl:when>
73     </xsl:choose>
74   </xsl:variable>
75
76   <xsl:call-template name="write.text.chunk">
77     <xsl:with-param name="filename"
78                     select="concat($base.dir, normalize-space ($name), '.', $section)"/>
79     <xsl:with-param name="content">
80       <xsl:text>.\"Generated by db2man.xsl. Don't modify this, modify the source.
81 .de Sh \" Subsection
82 .br
83 .if t .Sp
84 .ne 5
85 .PP
86 \fB\\$1\fR
87 .PP
88 ..
89 .de Sp \" Vertical space (when we can't use .PP)
90 .if t .sp .5v
91 .if n .sp
92 ..
93 .de Ip \" List item
94 .br
95 .ie \\n(.$>=3 .ne \\$3
96 .el .ne 3
97 .IP "\\$1" \\$2
98 ..
99 .TH "</xsl:text>
100       <xsl:value-of select="translate($reftitle,'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
101       <xsl:text>" </xsl:text>
102       <xsl:value-of select="refmeta/manvolnum[1]"/>
103       <xsl:text> "</xsl:text>
104       <xsl:value-of select="normalize-space($date)"/>
105       <xsl:text>" "</xsl:text>
106       <xsl:value-of select="normalize-space($productname)"/>
107       <xsl:text>" "</xsl:text>
108       <xsl:value-of select="$title"/>
109       <xsl:text>"
110 </xsl:text>
111       <xsl:apply-templates/>
112       <xsl:text>&#10;</xsl:text>
113
114       <!-- Author section -->
115       <xsl:choose>
116         <xsl:when test="refentryinfo//author">
117           <xsl:apply-templates select="refentryinfo" mode="authorsect"/>
118         </xsl:when>
119       </xsl:choose>
120     </xsl:with-param>
121   </xsl:call-template>
122 </xsl:template>
123
124 <xsl:template match="informalexample|screen|programlisting">
125   <xsl:text>.nf&#10;</xsl:text>
126   <xsl:apply-templates/>
127   <xsl:text>.fi&#10;</xsl:text>
128 </xsl:template>
129
130 <xsl:template match="//emphasis">
131   <xsl:text>\fB</xsl:text>
132   <xsl:apply-templates/>
133   <xsl:text>\fR</xsl:text>
134 </xsl:template>
135
136 <xsl:template match="para|simpara|remark" mode="list">
137   <xsl:variable name="foo">
138     <xsl:apply-templates/>
139   </xsl:variable>
140   <xsl:choose match="node()">
141     <!-- Don't normalize-space() for verbatim paragraphs        -->
142     <xsl:when test="informalexample|screen|programlisting">
143       <xsl:value-of select="$foo"/>
144     </xsl:when>
145     <xsl:otherwise>
146       <xsl:value-of select="normalize-space($foo)"/>
147       <xsl:text>&#10;</xsl:text>
148     </xsl:otherwise>
149   </xsl:choose>
150   <xsl:text>&#10;</xsl:text>
151   <xsl:if test="following-sibling::para or following-sibling::simpara or
152                 following-sibling::remark">
153     <!-- Make sure multiple paragraphs within a list item don't -->
154     <!-- merge together.                                        -->
155     <xsl:text>&#10;</xsl:text>
156   </xsl:if>
157 </xsl:template>
158
159 </xsl:stylesheet>