Created Debian package
[xmldoc.git] / html.xsl
1 <?xml version="1.0"?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version="1.0">
3
4 <xsl:strip-space elements="doc chapter section"/>
5 <xsl:output method="xml" indent="yes" encoding="iso-8859-1"
6             doctype-system="http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"
7             doctype-public="-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"/>
8
9 <xsl:template match="doc">
10 <xsl:element name="html" namespace="http://www.w3.org/1999/xhtml">
11 <head>
12    <meta charset="utf-8"/>
13    <link>
14    <xsl:attribute name="rel">stylesheet</xsl:attribute>
15    <xsl:attribute name="type">text/css</xsl:attribute>
16    <xsl:attribute name="href"><xsl:value-of select="@style"/></xsl:attribute>
17    </link>
18    <title>
19       <xsl:if test='not(*/titlepage/title)'>
20       -
21       </xsl:if>
22       <xsl:value-of select="*/titlepage/title"/>
23    </title>
24    <style type="text/css">
25       .center
26       {
27          text-align : center ;
28       }
29       table.docinfo
30       {
31          margin-left  : 10% ;
32          margin-right : 10% ;
33          border-style : solid ;
34       }
35       th
36       {
37          border-style : solid ;
38          border-width : thin ;
39       }
40       h3.toc
41       {
42          margin-left : 2em ;
43       }
44       pre.example
45       {
46          border : solid ;
47          padding-bottom : 1em ;
48       }
49       span.red
50       {
51          color : red ;
52       }
53       span.green
54       {
55          color : green ;
56       }
57       span.blue
58       {
59          color : blue ;
60       }
61       span.cyan
62       {
63          color : cyan ;
64       }
65       span.magenta
66       {
67          color : magenta ;
68       }
69       span.yellow
70       {
71          color : yellow ;
72       }
73       span.orange
74       {
75          color : orange ;
76       }
77       span.violet
78       {
79          color : violet ;
80       }
81       span.purple
82       {
83          color : purple ;
84       }
85       span.brown
86       {
87          color : brown ;
88       }
89       span.pink
90       {
91          color : pink ;
92       }
93       span.olive
94       {
95          color : olive ;
96       }
97       span.black
98       {
99          color : black ;
100       }
101       span.darkgray
102       {
103          color : darkgray ;
104       }
105       span.gray
106       {
107          color : gray ;
108       }
109       span.lightgray
110       {
111          color : lightgray ;
112       }
113       span.white
114       {
115          color : white ;
116       }
117    </style>
118 </head>
119
120 <body>
121    <xsl:apply-templates/>
122    <hr/>
123    <xsl:apply-templates select="//footnote" mode="footnotes"/>
124 </body>
125 </xsl:element>
126 </xsl:template>
127
128 <xsl:template match="titlepage">
129    <div>
130    <xsl:attribute name="class">titlepage</xsl:attribute>
131    <xsl:apply-templates/>
132    </div>
133 </xsl:template>
134
135 <xsl:template match="title">
136    <h1>
137    <xsl:attribute name="class">titlepage</xsl:attribute>
138    <xsl:apply-templates/>
139    </h1>
140 </xsl:template>
141
142 <xsl:template match="subtitle">
143    <h2>
144    <xsl:attribute name="class">titlepage</xsl:attribute>
145    <xsl:apply-templates/>
146    </h2>
147 </xsl:template>
148
149 <xsl:template match="author">
150    <xsl:apply-templates/><br/>
151 </xsl:template>
152
153 <xsl:template match="date">
154    <p><xsl:apply-templates/></p>
155 </xsl:template>
156
157 <xsl:template match="docinfo">
158    <table class="docinfo">
159    <tr><th colspan="2">Document Information</th></tr>
160    <xsl:apply-templates/>
161    </table>
162 </xsl:template>
163
164 <xsl:template match="infoitem">
165    <tr>
166      <td><xsl:value-of select="@label"/></td>
167      <td><xsl:apply-templates/></td>
168    </tr>
169 </xsl:template>
170
171 <xsl:template match="abstract">
172    <blockquote>
173    <p><b>Abstract:</b></p>
174    <p>
175    <xsl:apply-templates/>
176    </p>
177    </blockquote>
178 </xsl:template>
179
180 <!--  A template to create the section number for a node -->
181
182 <xsl:template name="section-number" mode="section-number" match="node()">
183    <xsl:number count="chapter|section" level="multiple" format="1.1 "/>
184 </xsl:template>
185
186 <!--  Create a table of contents -->
187
188 <xsl:template match="toc">
189 <h1>Table Of Contents</h1>
190 <xsl:for-each select="../chapter">
191    <h2>
192    <xsl:number count="chapter"/>
193    <xsl:text>  </xsl:text>
194    <a>
195    <xsl:attribute name="href">#CH<xsl:number count="chapter"/></xsl:attribute>
196    <xsl:value-of select="heading"/>
197    </a>
198    </h2>
199    <xsl:for-each select="section">
200       <h3 class="toc">
201       <xsl:number count="chapter|section" level="multiple" format="1.1 "/>
202       <a>
203       <xsl:attribute name="href">#SEC<xsl:number count="chapter|section" level="multiple" format="1.1"/></xsl:attribute>
204       <xsl:value-of select="heading"/>
205       </a>
206       </h3>
207    </xsl:for-each>
208 </xsl:for-each>
209 <hr></hr>
210 </xsl:template>
211
212 <!--  Chapter and section headings are all automatically numbered -->
213
214 <xsl:template match="chapter/heading">
215    <h1>
216      <xsl:number count="chapter"/>
217      <xsl:text>  </xsl:text>
218       <a>
219       <xsl:attribute name="id">CH<xsl:number count="chapter"/></xsl:attribute>
220       </a>
221      <xsl:apply-templates/>
222    </h1>
223 </xsl:template>
224
225 <xsl:template match="section/heading">
226    <h2>
227      <xsl:number count="chapter|section" level="multiple" format="1.1 "/>
228      <a>
229      <xsl:attribute name="id">SEC<xsl:number count="chapter|section" level="multiple" format="1.1"/></xsl:attribute>
230      </a>
231      <xsl:apply-templates/>
232    </h2>
233 </xsl:template>
234
235 <xsl:template match="subsection/heading">
236    <h3>
237      <xsl:number count="chapter|section|subsection" level="multiple" format="1.1.1 "/>
238      <xsl:apply-templates/>
239    </h3>
240 </xsl:template>
241
242 <xsl:template match="subsubsection/heading">
243    <h4>
244      <xsl:number count="chapter|section|subsection|subsubsection" level="multiple"
245                  format="1.1.1.1 "/>
246      <xsl:apply-templates/>
247    </h4>
248 </xsl:template>
249
250 <xsl:template match="paragraph/heading">
251    <h4>
252      <xsl:number count="chapter|section|subsection|subsubsection|paragraph"
253                  level="multiple"
254                  format="1.1.1.1.1 "/>
255      <xsl:apply-templates/>
256    </h4>
257 </xsl:template>
258
259 <xsl:template match="subparagraph/heading">
260    <h4>
261      <xsl:number count="chapter|section|subsection|subsubsection|paragraph|subparagraph"
262                  level="multiple"
263                  format="1.1.1.1.1.1 "/>
264      <xsl:apply-templates/>
265    </h4>
266 </xsl:template>
267
268 <!--  Trivial elements are convreted directly -->
269
270 <xsl:template match="para">
271    <p>
272      <xsl:apply-templates/>
273    </p>
274 </xsl:template>
275
276 <xsl:template match="quote">
277    <blockquote><p>
278      <xsl:apply-templates/>
279    </p></blockquote>
280 </xsl:template>
281
282 <xsl:template match="verbatim">
283 <pre>
284  <xsl:apply-templates/>
285 </pre>
286 </xsl:template>
287
288 <xsl:template match="example">
289 <pre class='example'>
290  <xsl:apply-templates/>
291 </pre>
292 </xsl:template>
293
294 <xsl:template match="itemize">
295 <ul>
296    <xsl:apply-templates/>
297 </ul>
298 </xsl:template>
299
300 <xsl:template match="enumerate">
301 <ol>
302    <xsl:apply-templates/>
303 </ol>
304 </xsl:template>
305
306 <xsl:template match="description">
307 <dl>
308    <xsl:apply-templates/>
309 </dl>
310 </xsl:template>
311
312 <xsl:template match="itemize/item">
313 <li>
314    <xsl:apply-templates/>
315 </li>
316 </xsl:template>
317
318 <xsl:template match="enumerate/item">
319 <li>
320    <xsl:apply-templates/>
321 </li>
322 </xsl:template>
323
324 <xsl:template match="description/item">
325 <dt><xsl:value-of select='@tag'/></dt>
326 <dd>
327    <xsl:apply-templates/>
328 </dd>
329 </xsl:template>
330
331 <xsl:template match="footnote">
332 <sup><a>
333   <xsl:attribute name='href'>#footnote<xsl:number level='any'/></xsl:attribute>
334   <xsl:number level='any'/>
335 </a></sup>
336 </xsl:template>
337
338 <xsl:template match="footnote" mode="footnotes">
339 <p>
340 <sup><a><xsl:attribute name='id'>footnote<xsl:number level='any'/></xsl:attribute>
341         <xsl:number level='any'/></a></sup> <xsl:apply-templates/>
342 </p>
343 </xsl:template>
344
345 <xsl:template match="emph">
346 <em><xsl:apply-templates/></em>
347 </xsl:template>
348
349 <xsl:template match="strong">
350 <strong><xsl:apply-templates/></strong>
351 </xsl:template>
352
353 <xsl:template match="code">
354 <code><xsl:apply-templates/></code>
355 </xsl:template>
356
357 <xsl:template match="remark">
358 <span><xsl:attribute name="class">remark</xsl:attribute><xsl:apply-templates/></span>
359 </xsl:template>
360
361 <xsl:template match="sub">
362 <sub><xsl:apply-templates/></sub>
363 </xsl:template>
364
365 <xsl:template match="sup">
366 <sup><xsl:apply-templates/></sup>
367 </xsl:template>
368
369 <xsl:template match="color">
370 <span><xsl:attribute name="class"><xsl:value-of select="@colorname"/></xsl:attribute><xsl:apply-templates/></span>
371 </xsl:template>
372
373 <xsl:template match="big">
374 <big><xsl:apply-templates/></big>
375 </xsl:template>
376
377 <xsl:template match="small">
378 <small><xsl:apply-templates/></small>
379 </xsl:template>
380
381 <xsl:template match="table">
382 <table>
383 <xsl:apply-templates/>
384 </table>
385 </xsl:template>
386
387 <xsl:template match="newline"><br/></xsl:template>
388
389 <xsl:template match="row">
390 <tr><xsl:apply-templates/></tr>
391 </xsl:template>
392
393 <xsl:template match="thead">
394 <tr><xsl:apply-templates/></tr>
395 </xsl:template>
396
397 <xsl:template match="thead/col">
398 <th><xsl:apply-templates/></th>
399 </xsl:template>
400
401 <xsl:template match="row/col">
402 <td><xsl:apply-templates/></td>
403 </xsl:template>
404
405 <xsl:template match="picture">
406    <img><xsl:attribute name="src"><xsl:value-of select="@src"/></xsl:attribute>
407    </img>
408 </xsl:template>
409
410 <xsl:template match="label">
411    <a><xsl:attribute name='id'>
412       <xsl:value-of select="@name"/>
413    </xsl:attribute></a>
414 </xsl:template>
415
416 <xsl:template match="index"></xsl:template>
417
418 <xsl:template match="ref">
419    <a><xsl:attribute name='href'>#<xsl:value-of select="@to"/></xsl:attribute>
420      <xsl:apply-templates/>
421      <!--<xsl:apply-templates select="id(@to)" mode="section-number"/>-->
422    </a>
423 </xsl:template>
424
425 <xsl:template match="page"></xsl:template>
426
427 <xsl:template match="reference">
428 <a>
429 <xsl:attribute name="href">
430 <xsl:value-of select="@href"/>
431 </xsl:attribute>
432 <xsl:apply-templates/>
433 </a>
434 </xsl:template>
435
436 <xsl:template match="math">
437 <xsl:element name="math" namespace="http://www.w3.org/1998/Math/MathML">
438    <xsl:copy-of select='./*'/>
439 </xsl:element>
440 </xsl:template>
441
442 <xsl:template match="svg">
443 <xsl:if test='@src'>
444    <xsl:copy-of select="document(@src)"/>
445 </xsl:if>
446 <xsl:if test='not(@src)'>
447    <xsl:element name="svg" namespace="http://www.w3.org/2000/svg">
448       <xsl:copy-of select='./*'/>
449    </xsl:element>
450 </xsl:if>
451 </xsl:template>
452
453
454
455 </xsl:stylesheet>