Added <description> element for description lists
[xmldoc.git] / html.xsl
1 <?xml version="1.0"?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
3
4 <xsl:strip-space elements="doc chapter section"/>
5 <xsl:output method="html" indent="yes" encoding="iso-8859-1"/>
6
7 <xsl:template match="doc">
8 <html>
9 <head>
10    <link>
11    <xsl:attribute name="rel">stylesheet</xsl:attribute>
12    <xsl:attribute name="type">text/css</xsl:attribute>
13    <xsl:attribute name="href"><xsl:value-of select="@style"/></xsl:attribute>
14    </link>
15    <title>
16       <xsl:value-of select="*/titlepage/title"/>
17    </title>
18 </head>
19 <body>
20    <xsl:apply-templates/>
21    <hr/>
22    <xsl:apply-templates select="//footnote" mode="footnotes"/>
23 </body>
24 </html>
25 </xsl:template>
26
27 <xsl:template match="titlepage">
28    <div>
29    <xsl:attribute name="class">titlepage</xsl:attribute>
30    <xsl:apply-templates/>
31    </div>
32 </xsl:template>
33
34 <xsl:template match="title">
35    <h1>
36    <xsl:attribute name="class">titlepage</xsl:attribute>
37    <xsl:apply-templates/>
38    </h1>
39 </xsl:template>
40
41 <xsl:template match="subtitle">
42    <h2>
43    <xsl:attribute name="class">titlepage</xsl:attribute>
44    <xsl:apply-templates/>
45    </h2>
46 </xsl:template>
47
48 <xsl:template match="author">
49    <xsl:apply-templates/><br/>
50 </xsl:template>
51
52 <xsl:template match="date">
53    <p><xsl:apply-templates/></p>
54 </xsl:template>
55
56 <xsl:template match="docinfo">
57    <center><table border="2" width="90%">
58    <tr><th colspan="2">Document Information</th></tr>
59    <xsl:apply-templates/>
60    </table></center>
61 </xsl:template>
62
63 <xsl:template match="infoitem">
64    <tr>
65      <td><xsl:value-of select="@label"/></td>
66      <td><xsl:apply-templates/></td>
67    </tr>
68 </xsl:template>
69
70 <xsl:template match="abstract">
71    <blockquote>
72    <b>Abstract:</b><br/>
73    <xsl:apply-templates/>
74    </blockquote>
75 </xsl:template>
76
77 <!--  A template to create the section number for a node -->
78
79 <xsl:template name="section-number" mode="section-number" match="node()">
80    <xsl:number count="chapter|section" level="multiple" format="1.1 "/>
81 </xsl:template>
82
83 <!--  Create a table of contents -->
84
85 <xsl:template match="toc">
86 <h1>Table Of Contents</h1>
87 <xsl:for-each select="../chapter">
88    <h2>
89    <xsl:number count="chapter"/>
90    <xsl:text>  </xsl:text>
91    <a>
92    <xsl:attribute name="href">#CH<xsl:number count="chapter"/></xsl:attribute>
93    <xsl:value-of select="heading"/>
94    </a>
95    </h2>
96    <ul>
97    <xsl:for-each select="section">
98       <h3>
99       <xsl:number count="chapter|section" level="multiple" format="1.1 "/>
100       <a>
101       <xsl:attribute name="href">#SEC<xsl:number count="chapter|section" level="multiple" format="1.1"/></xsl:attribute>
102       <xsl:value-of select="heading"/>
103       </a>
104       </h3>
105    </xsl:for-each>
106    </ul>
107 </xsl:for-each>
108 <hr></hr>
109 </xsl:template>
110
111 <!--  Chapter and section headings are all automatically numbered -->
112
113 <xsl:template match="chapter/heading">
114    <h1>
115      <xsl:number count="chapter"/>
116      <xsl:text>  </xsl:text>
117       <a>
118       <xsl:attribute name="name">CH<xsl:number count="chapter"/></xsl:attribute>
119       </a>
120      <xsl:apply-templates/>
121    </h1>
122 </xsl:template>
123
124 <xsl:template match="section/heading">
125    <h2>
126      <xsl:number count="chapter|section" level="multiple" format="1.1 "/>
127      <a>
128      <xsl:attribute name="name">SEC<xsl:number count="chapter|section" level="multiple" format="1.1"/></xsl:attribute>
129      </a>
130      <xsl:apply-templates/>
131    </h2>
132 </xsl:template>
133
134 <xsl:template match="subsection/heading">
135    <h3>
136      <xsl:number count="chapter|section|subsection" level="multiple" format="1.1.1 "/>
137      <xsl:apply-templates/>
138    </h3>
139 </xsl:template>
140
141 <xsl:template match="subsubsection/heading">
142    <h4>
143      <xsl:number count="chapter|section|subsection|subsubsection" level="multiple"
144                  format="1.1.1.1 "/>
145      <xsl:apply-templates/>
146    </h4>
147 </xsl:template>
148
149 <xsl:template match="paragraph/heading">
150    <h4>
151      <xsl:number count="chapter|section|subsection|subsubsection|paragraph"
152                  level="multiple"
153                  format="1.1.1.1.1 "/>
154      <xsl:apply-templates/>
155    </h4>
156 </xsl:template>
157
158 <xsl:template match="subparagraph/heading">
159    <h4>
160      <xsl:number count="chapter|section|subsection|subsubsection|paragraph|subparagraph"
161                  level="multiple"
162                  format="1.1.1.1.1.1 "/>
163      <xsl:apply-templates/>
164    </h4>
165 </xsl:template>
166
167 <!--  Trivial elements are convreted directly -->
168
169 <xsl:template match="para">
170    <p>
171      <xsl:apply-templates/>
172    </p>
173 </xsl:template>
174
175 <xsl:template match="quote">
176    <blockquote>
177      <xsl:apply-templates/>
178    </blockquote>
179 </xsl:template>
180
181 <xsl:template match="verbatim">
182 <pre>
183  <xsl:apply-templates/>
184 </pre>
185 </xsl:template>
186
187 <xsl:template match="itemize">
188 <ul>
189    <xsl:apply-templates/>
190 </ul>
191 </xsl:template>
192
193 <xsl:template match="enumerate">
194 <ol>
195    <xsl:apply-templates/>
196 </ol>
197 </xsl:template>
198
199 <xsl:template match="description">
200 <dl>
201    <xsl:apply-templates/>
202 </dl>
203 </xsl:template>
204
205 <xsl:template match="itemize/item">
206 <li>
207    <xsl:apply-templates/>
208 </li>
209 </xsl:template>
210
211 <xsl:template match="enumerate/item">
212 <li>
213    <xsl:apply-templates/>
214 </li>
215 </xsl:template>
216
217 <xsl:template match="description/item">
218 <dt><xsl:value-of select='@tag'/></dt>
219 <dd>
220    <xsl:apply-templates/>
221 </dd>
222 </xsl:template>
223
224 <xsl:template match="footnote">
225 <sup><a>
226   <xsl:attribute name='href'>#footnote<xsl:number level='any'/></xsl:attribute>
227   <xsl:number level='any'/>
228 </a></sup>
229 </xsl:template>
230
231 <xsl:template match="footnote" mode="footnotes">
232 <sup><a><xsl:attribute name='name'>footnote<xsl:number level='any'/></xsl:attribute>
233         <xsl:number level='any'/></a></sup> <xsl:apply-templates/><br/>
234
235 </xsl:template>
236
237 <xsl:template match="emph">
238 <em><xsl:apply-templates/></em>
239 </xsl:template>
240
241 <xsl:template match="strong">
242 <strong><xsl:apply-templates/></strong>
243 </xsl:template>
244
245 <xsl:template match="code">
246 <code><xsl:apply-templates/></code>
247 </xsl:template>
248
249 <xsl:template match="remark">
250 <span><xsl:attribute name="class">remark</xsl:attribute><xsl:apply-templates/></span>
251 </xsl:template>
252
253 <xsl:template match="sub">
254 <sub><xsl:apply-templates/></sub>
255 </xsl:template>
256
257 <xsl:template match="sup">
258 <sup><xsl:apply-templates/></sup>
259 </xsl:template>
260
261 <xsl:template match="table">
262 <table>
263 <xsl:apply-templates/>
264 </table>
265 </xsl:template>
266
267 <xsl:template match="newline"><br/></xsl:template>
268
269 <xsl:template match="row">
270 <tr><xsl:apply-templates/></tr>
271 </xsl:template>
272
273 <xsl:template match="thead">
274 <tr><xsl:apply-templates/></tr>
275 </xsl:template>
276
277 <xsl:template match="thead/col">
278 <th><xsl:apply-templates/></th>
279 </xsl:template>
280
281 <xsl:template match="row/col">
282 <td><xsl:apply-templates/></td>
283 </xsl:template>
284
285 <xsl:template match="picture">
286    <img><xsl:attribute name="src"><xsl:value-of select="@src"/></xsl:attribute>
287    </img>
288 </xsl:template>
289
290 <xsl:template match="label">
291    <a><xsl:attribute name='name'>
292       <xsl:value-of select="@name"/>
293    </xsl:attribute></a>
294 </xsl:template>
295
296 <xsl:template match="index"></xsl:template>
297
298 <xsl:template match="ref">
299    <a><xsl:attribute name='href'>#<xsl:value-of select="@to"/></xsl:attribute>
300      <xsl:apply-templates/>
301      <!--<xsl:apply-templates select="id(@to)" mode="section-number"/>-->
302    </a>
303 </xsl:template>
304
305 <xsl:template match="page"></xsl:template>
306
307 <xsl:template match="reference">
308 <a>
309 <xsl:attribute name="href">
310 <xsl:value-of select="@href"/>
311 </xsl:attribute>
312 <xsl:apply-templates/>
313 </a>
314 </xsl:template>
315
316 </xsl:stylesheet>
317