1<?xml version="1.0"?>
2
3<!--
4   - html.xsl -
5   -
6   - Copyright (c) 2000 Zveno Pty Ltd
7   -
8   -	XSLT stylesheet to convert DocBook+Tcl mods to HTML.
9   -
10   - $Id: html.xsl,v 1.1 2002/05/30 13:20:13 balls Exp $
11   -->
12
13<xsl:stylesheet version='1.0'
14        xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
15
16<!-- Import standard DocBook stylesheets
17   -
18   - We import, rather than include, so that templates defined here 
19   - have higher priority.
20   -
21   - NB. 'docbook' must be a symbolic link (or equivalent) to
22   - DocBook stylesheets (v1.14 or later).
23  -->
24
25<xsl:import href='docbook/xsl/html/docbook.xsl'/>
26
27<!-- Provide a template which adds a TOC -->
28
29<xsl:template match="refentry">
30  <xsl:variable name="refmeta" select=".//refmeta"/>
31  <xsl:variable name="refentrytitle" select="$refmeta//refentrytitle"/>
32  <xsl:variable name="refnamediv" select=".//refnamediv"/>
33  <xsl:variable name="refname" select="$refnamediv//refname"/>
34  <xsl:variable name="title">
35    <xsl:choose>
36      <xsl:when test="$refentrytitle">
37        <xsl:apply-templates select="$refentrytitle[1]" mode="title"/>
38      </xsl:when>
39      <xsl:when test="$refname">
40        <xsl:apply-templates select="$refname[1]" mode="title"/>
41      </xsl:when>
42      <xsl:otherwise></xsl:otherwise>
43    </xsl:choose>
44  </xsl:variable>
45
46  <div class="{name(.)}">
47    <h1 class="title">
48      <a>
49        <xsl:attribute name="name">
50          <xsl:call-template name="object.id"/>
51        </xsl:attribute>
52        <xsl:copy-of select="$title"/>
53      </a>
54    </h1>
55    <h2>Contents</h2>
56    <ul>
57      <xsl:if test="refsynopsisdiv">
58	<li><a href="#synopsis">Synopsis</a></li>
59      </xsl:if>
60      <xsl:for-each select="refsect1">
61	<xsl:variable name="sect1name" select="translate(title,' ','-')"/>
62	<li>
63	  <a href="#{$sect1name}"><xsl:value-of select="title"/></a>
64	  <xsl:if test="refsect2">
65	    <ul>
66	      <xsl:for-each select="refsect2">
67		<xsl:variable name="sect2name" select="translate(title,' ','-')"/>
68		<li>
69		  <a href="#{$sect1name}-{$sect2name}"><xsl:value-of select="title"/></a>
70		  <xsl:if test="refsect3">
71		    <ul>
72		      <xsl:for-each select="refsect3">
73			<xsl:variable name="sect3name" select="translate(title,' ','-')"/>
74			<li>
75			  <a href="#{$sect1name}-{$sect2name}-{$sect3name}"><xsl:value-of select="title"/></a>
76			</li>
77		      </xsl:for-each>
78		    </ul>
79		  </xsl:if>
80		</li>
81	      </xsl:for-each>
82	    </ul>
83	  </xsl:if>
84	</li>
85      </xsl:for-each>
86    </ul>
87    <xsl:apply-templates/>
88    <xsl:call-template name="process.footnotes"/>
89  </div>
90</xsl:template>
91
92<xsl:template match="refsynopsisdiv">
93  <div class="{name(.)}">
94    <a name="synopsis">
95    </a>
96    <h2>Synopsis</h2>
97    <xsl:apply-templates select="*[name() != 'tclnamespacesynopsis']"/>
98    <xsl:apply-templates select="tclnamespacesynopsis"/>
99  </div>
100</xsl:template>
101
102<xsl:template match="tclcmdsynopsis">
103  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
104
105  <div class="{name(.)}" id="{$id}">
106    <a name="{$id}"/>
107    <xsl:apply-templates/>
108  </div>
109</xsl:template>
110<xsl:template match="tclcmdsynopsis/command">
111  <br/>
112  <xsl:call-template name="inline.monoseq"/>
113  <xsl:text> </xsl:text>
114</xsl:template>
115<xsl:template match="tclcmdsynopsis/command[1]">
116  <xsl:call-template name="inline.monoseq"/>
117  <xsl:text> </xsl:text>
118</xsl:template>
119
120<xsl:template match="refsynopsisdiv/tclcmdsynopsis/command">
121  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
122
123  <br/>
124  <span class="{name(.)}" id="{$id}">
125    <a name="{translate(.,': ','__')}"/>
126    <xsl:call-template name="inline.monoseq"/>
127    <xsl:text> </xsl:text>
128  </span>
129</xsl:template>
130<xsl:template match="refsynopsisdiv/tclcmdsynopsis/command[1]">
131  <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
132
133  <span class="{name(.)}" id="{$id}">
134    <a name="{translate(.,': ','__')}"/>
135    <xsl:call-template name="inline.monoseq"/>
136    <xsl:text> </xsl:text>
137  </span>
138</xsl:template>
139<xsl:template match="tclcmdsynopsis/option">
140  <u><xsl:apply-templates/></u>
141</xsl:template>
142<xsl:template match="tclcmdsynopsis/group">
143  <xsl:if test="@choice='opt'">
144    <xsl:text>?</xsl:text>
145  </xsl:if>
146  <xsl:apply-templates/>
147  <xsl:if test="@rep='repeat'">
148    <xsl:text>...</xsl:text>
149  </xsl:if>
150  <xsl:if test="@choice='opt'">
151    <xsl:text>?</xsl:text>
152  </xsl:if>
153</xsl:template>
154<xsl:template match="tclcmdsynopsis//arg[1]">
155  <xsl:apply-templates/>
156</xsl:template>
157<xsl:template match="tclcmdsynopsis//arg[position() > 1]">
158  <xsl:text> </xsl:text>
159  <xsl:apply-templates/>
160</xsl:template>
161
162<xsl:template match="tclcommand">
163  <a href="#{translate(.,': ','__')}">
164    <xsl:call-template name="inline.boldseq"/>
165  </a>
166</xsl:template>
167
168<xsl:template match='tclpackage|tclnamespace'>
169  <xsl:call-template name='inline.monoseq'/>
170</xsl:template>
171
172<xsl:template match="tclpkgsynopsis">
173  <br/>
174  <span class="{name(.)}">
175    <pre>package require <xsl:value-of select="package"/> ?<xsl:value-of select="version"/>?</pre>
176  </span>
177</xsl:template>
178
179<xsl:template match="tclnamespacesynopsis">
180  <h3>Tcl Namespace Usage</h3>
181  <xsl:apply-templates/>
182  <p/>
183</xsl:template>
184
185<xsl:template match="tclnamespacesynopsis/tclnamespace[1]">
186  <xsl:call-template name="inline.monoseq"/>
187</xsl:template>
188
189<xsl:template match="tclnamespacesynopsis/tclnamespace">
190  <br/>
191  <xsl:call-template name="inline.monoseq"/>
192</xsl:template>
193
194<xsl:template match="refsect1[title = 'Commands'][refsect2/title]//tclcmdsynopsis/*[position() = 1 and name() = 'option']">
195  <tt>
196    <xsl:choose>
197      <xsl:when test="ancestor::refsect3//*[@role='subject']">
198        <i><xsl:value-of select="ancestor::refsect3//*[@role='subject']"/></i>
199      </xsl:when>
200      <xsl:when test="ancestor::refsect2/title">
201	<xsl:value-of select="ancestor::refsect2/title"/>
202      </xsl:when>
203      <xsl:otherwise/>
204    </xsl:choose>
205  </tt>
206  <xsl:text> </xsl:text>
207  <u><xsl:apply-templates/></u>
208</xsl:template>
209
210<xsl:template match="tcloptionsynopsis">
211  <p>
212    <xsl:apply-templates/>
213  </p>
214</xsl:template>
215
216<xsl:template match="tcloptionsynopsis/option">
217  <xsl:call-template name="inline.monoseq"/>
218</xsl:template>
219
220<xsl:template match="tcloptionsynopsis/arg">
221  <u>
222    <xsl:apply-templates/>
223  </u>
224</xsl:template>
225
226<!-- Do a segmentedlist as a table, instead of the poxy way DocBook does them -->
227
228<xsl:template match="segmentedlist">
229  <table border="0">
230    <xsl:apply-templates/>
231  </table>
232</xsl:template>
233
234<xsl:template match="seglistitem">
235  <tr>
236    <xsl:apply-templates/>
237  </tr>
238</xsl:template>
239
240<xsl:template match="seg">
241  <td valign="top">
242    <xsl:apply-templates/>
243  </td>
244</xsl:template>
245
246<xsl:template match="seg/arg">
247  <xsl:call-template name="inline.monoseq"/>
248</xsl:template>
249
250</xsl:stylesheet>
251