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