1
<?xml version="1.0" encoding="ISO-8859-1"?>
5
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
6
xmlns="http://www.w3.org/1999/xhtml">
8
<xsl:output method="xml" version="1.0"
9
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
10
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>
12
<!-- Print an error when an element is not matched -->
14
<xsl:template match="*">
15
<div class="error">Unmatched element</div>
19
<!-- Root templates -->
21
<xsl:template match="/TeXmacs">
22
<xsl:apply-templates/>
25
<xsl:template match="/TeXmacs/*"/>
27
<xsl:template match="/TeXmacs/body">
28
<html lang="en" xml:lang="en">
30
<title><xsl:value-of select="tm-par/doc-data/doc-title"/></title>
31
<link rel="stylesheet" href="texmacs.css" type="text/css"/>
34
<xsl:apply-templates/>
40
<!-- Paragraph formating -->
42
<xsl:template match="body/tm-par">
43
<p><xsl:apply-templates/></p>
46
<xsl:template match="no-page-break|no-page-break_42_"/>
48
<xsl:template match="new-page|new-page_42_"/>
53
<xsl:template match="tm-par[doc-data]|doc-data">
54
<xsl:apply-templates/>
57
<xsl:template match="doc-title">
58
<h1><xsl:apply-templates/></h1>
61
<xsl:template match="tm-par[section|subsection|subsubsection]">
62
<xsl:apply-templates/>
65
<xsl:template match="section">
67
<xsl:value-of select="count(preceding::section) + 1"/>
68
<xsl:text>. </xsl:text>
69
<xsl:apply-templates/>
73
<xsl:template match="subsection">
75
<xsl:value-of select="count(preceding::section)"/>
76
<xsl:text>.</xsl:text>
77
<xsl:value-of select="count(preceding::subsection[generate-id(preceding::section[1]) = generate-id(current()/preceding::section[1])]) + 1"/>
78
<xsl:text>. </xsl:text>
79
<xsl:apply-templates/>
83
<xsl:template match="subsubsection">
85
<xsl:value-of select="count(preceding::section)"/>
86
<xsl:text>.</xsl:text>
87
<xsl:value-of select="count(preceding::subsection[generate-id(preceding::section[1]) = generate-id(current()/preceding::section[1])])"/>
88
<xsl:text>.</xsl:text>
89
<xsl:value-of select="count(preceding::subsubsection[generate-id(preceding::subsection[1]) = generate-id(current()/preceding::subsection[1])]) + 1"/>
90
<xsl:text>. </xsl:text>
91
<xsl:apply-templates/>
95
<xsl:template match="paragraph">
96
<strong><xsl:apply-templates/><xsl:text> </xsl:text></strong>
100
<!-- Unordered lists -->
102
<xsl:template match="tm-par[itemize]">
103
<xsl:apply-templates/>
106
<xsl:template match="itemize">
107
<ul><xsl:apply-templates/></ul>
110
<xsl:template match="itemize/tm-par[item]">
111
<li><xsl:apply-templates/></li>
114
<xsl:template match="itemize/tm-par/item"/>
117
<!-- Description lists -->
119
<xsl:template match="tm-par[description-long|description-dash]">
120
<xsl:apply-templates/>
123
<xsl:template match="description-long|description-dash">
124
<dl><xsl:apply-templates/></dl>
127
<xsl:template match="description-long/tm-par[item_42_]">
128
<xsl:call-template name="description-para"/>
131
<xsl:template match="description-dash/tm-par[item_42_]">
132
<xsl:call-template name="description-para"/>
135
<xsl:template name="description-para">
136
<dt><xsl:apply-templates select="item_42_/child::node()"/></dt>
137
<dd><xsl:apply-templates/></dd>
140
<xsl:template match="description-long/tm-par/item_42_"/>
142
<xsl:template match="description-dash/tm-par/item_42_"/>
147
<xsl:template match="tm-par[big-figure]|big-figure/tm-arg">
148
<xsl:apply-templates/>
151
<xsl:template match="big-figure">
152
<div class="big-figure">
153
<div class="figure-body">
154
<xsl:apply-templates select="tm-arg[1]"/>
156
<div class="figure-caption">
158
<xsl:text>Figure </xsl:text>
159
<xsl:value-of select="count(preceding::big-figure) + 1"/>
160
<xsl:text>: </xsl:text>
162
<xsl:apply-templates select="tm-arg[2]"/>
167
<xsl:template match="postscript">
169
<xsl:attribute name="src">
170
<xsl:value-of select="tm-arg[1]"/>
172
<xsl:attribute name="alt">
173
<xsl:value-of select="tm-arg[1]"/>
179
<!-- Text styling -->
181
<xsl:template match="tm-par[with/tm-par]">
182
<xsl:apply-templates/>
185
<xsl:template match="with[@color='dark red']">
186
<span class="dark-red"><xsl:apply-templates/></span>
189
<xsl:template match="with[@color='dark red'][tm-par]">
191
<xsl:apply-templates select="tm-par/child::node()"/>
195
<xsl:template match="with[@color='red']">
196
<span class="red"><xsl:apply-templates/></span>
199
<xsl:template match="with[@font-shape='small-caps']">
200
<span class="small-caps"><xsl:apply-templates/></span>
203
<xsl:template match="with[@font-shape='italic']">
204
<i><xsl:apply-templates/></i>
207
<xsl:template match="verbatim">
208
<tt><xsl:apply-templates/></tt>
211
<xsl:template match="em">
212
<em><xsl:apply-templates/></em>
217
<xsl:template match="hlink">
219
<xsl:attribute name="href">
220
<xsl:value-of select="tm-arg[2]"/>
222
<xsl:apply-templates select="tm-arg[1]"/>
226
<xsl:template match="hlink/tm-arg">
227
<xsl:apply-templates/>