1
<?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
3
This program is free software; you can redistribute it and/or modify it under
4
the terms of the GNU Lesser General Public License as published by the Free
5
Software Foundation; either version 2 of the License, or (at your option) any
8
This program is distributed in the hope that it will be useful, but WITHOUT
9
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13
You should have received a copy of the GNU Lesser General Public License
14
along with this program; see the file COPYING.LGPL. If not, write to the
15
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
20
xmlns:mal="http://projectmallard.org/1.0/"
21
xmlns:e="http://projectmallard.org/experimental/"
22
xmlns="http://www.w3.org/1999/xhtml"
23
exclude-result-prefixes="mal e"
26
<!--!!==========================================================================
27
Mallard to HTML - Inlines
28
Handle simple Mallard block elements.
29
:Revision:version="1.0" date="2010-06-03" status="final"
31
This stylesheet contains templates to handle most Mallard inline elements.
34
<xsl:template mode="mal.link.content.mode" match="*">
35
<xsl:apply-templates mode="mal2html.inline.mode" select="."/>
39
<!--%%==========================================================================
41
Process Mallard elements in inline mode.
42
:Revision:version="1.0" date="2010-06-03" status="final"
44
This mode is applied to elements in inline context. It is be called by certain
45
block elements and inline elements to process child content. Certain elements
46
may appear in both block an inline mode, and the processing expectations for
47
those elements is different depending on context.
49
Implementations of this mode should handle ubiquitous linking, text directionality,
50
and other common inline features. Note that the *{mal2html.span} template handles
51
these things automatically, and is suitable for most inline elements. You can use
52
the %{mal2html.inline.content.mode} to output special content for the child
55
<xsl:template mode="mal2html.inline.mode" match="*">
57
<xsl:text>Unmatched inline element: </xsl:text>
58
<xsl:value-of select="local-name(.)"/>
60
<xsl:apply-templates mode="mal2html.inline.mode"/>
64
<!--%%==========================================================================
65
mal2html.inline.content.mode
66
Output the contents of an inline element.
67
:Revision:version="1.0" date="2010-06-03" status="final"
69
This template outputs the contents of the inline element it matches. It is
70
usually called by *{mal2html.span} to allow elements like #{guiseq}, #{keyseq},
71
and #{link} output special inner contents while still using the generic wrapper
74
<xsl:template mode="mal2html.inline.content.mode" match="node()">
75
<xsl:apply-templates mode="mal2html.inline.mode"/>
79
<!--**==========================================================================
81
Output an HTML #{span} element.
82
:Revision:version="1.0" date="2010-06-03" status="final"
83
$node: The source element to output a #{span} for.
84
$class: An additional string to prepend to the #{class} attribute.
86
This template outputs an HTML #{span} element for a source element. It creates
87
a #{class} attribute automatically from the #{class} attribute of ${node},
88
prepending any value set in the ${class} parameter. To output the contents
89
of ${node}, it applies the mode %{mal2html.inline.content.mode} to ${node}.
91
This template automatically handles ubiquitous linking if ${node} contains
92
an #{xref} or #{href} attribute.
94
<xsl:template name="mal2html.span">
95
<xsl:param name="node" select="."/>
96
<xsl:param name="class" select="''"/>
97
<span class="{concat($class, ' ', local-name($node))}">
98
<xsl:call-template name="html.lang.attrs"/>
100
<xsl:when test="$node/@xref | $node/@href">
102
<xsl:attribute name="href">
103
<xsl:call-template name="mal.link.target">
104
<xsl:with-param name="node" select="$node"/>
107
<xsl:attribute name="title">
108
<xsl:call-template name="mal.link.tooltip">
109
<xsl:with-param name="node" select="$node"/>
112
<xsl:apply-templates mode="mal2html.inline.content.mode" select="$node"/>
116
<xsl:apply-templates mode="mal2html.inline.content.mode" select="$node"/>
123
<!-- == Matched Templates == -->
126
<xsl:template mode="mal2html.inline.mode" match="mal:app">
127
<xsl:call-template name="mal2html.span"/>
131
<xsl:template mode="mal2html.inline.mode" match="mal:cmd">
132
<xsl:call-template name="mal2html.span"/>
136
<xsl:template mode="mal2html.inline.mode" match="mal:code">
137
<xsl:call-template name="mal2html.span"/>
141
<xsl:template mode="mal2html.inline.mode" match="mal:date">
142
<xsl:call-template name="mal2html.span"/>
146
<xsl:template mode="mal2html.inline.mode" match="mal:em">
147
<xsl:call-template name="mal2html.span">
148
<xsl:with-param name="class">
149
<xsl:if test="contains(concat(' ', @style, ' '), ' strong ')">
150
<xsl:text>em-bold</xsl:text>
157
<xsl:template mode="mal2html.inline.mode" match="mal:file">
158
<xsl:call-template name="mal2html.span"/>
162
<xsl:template mode="mal2html.inline.mode" match="mal:gui">
163
<xsl:call-template name="mal2html.span"/>
167
<xsl:template mode="mal2html.inline.mode" match="mal:guiseq">
168
<xsl:call-template name="mal2html.span"/>
171
<!-- = guiseq % mal2html.inline.content.mode = -->
172
<xsl:template mode="mal2html.inline.content.mode" match="mal:guiseq">
173
<xsl:variable name="arrow">
174
<xsl:variable name="dir">
175
<xsl:call-template name="l10n.direction">
176
<xsl:with-param name="lang" select="ancestor-or-self::*[@xml:lang][1]/@xml:lang"/>
180
<xsl:when test="$dir = 'rtl'">
181
<xsl:text> ◂ </xsl:text>
184
<xsl:text> ▸ </xsl:text>
188
<xsl:for-each select="mal:gui | text()[normalize-space(.) != '']">
189
<xsl:if test="position() != 1">
190
<xsl:value-of select="$arrow"/>
192
<xsl:apply-templates mode="mal2html.inline.mode" select="."/>
197
<xsl:template mode="mal2html.inline.mode" match="mal:input">
198
<xsl:call-template name="mal2html.span"/>
202
<xsl:template mode="mal2html.inline.mode" match="e:hi">
203
<xsl:call-template name="mal2html.span"/>
207
<xsl:template mode="mal2html.inline.mode" match="mal:key">
208
<xsl:call-template name="mal2html.span"/>
212
<xsl:template mode="mal2html.inline.mode" match="mal:keyseq">
213
<xsl:call-template name="mal2html.span"/>
216
<!-- = keyseq % mal2html.inline.content.mode = -->
217
<xsl:template mode="mal2html.inline.content.mode" match="mal:keyseq">
218
<xsl:variable name="joinchar">
220
<xsl:when test="@type = 'sequence'">
221
<xsl:text> </xsl:text>
223
<xsl:when test="contains(concat(' ', @style, ' '), ' hyphen ')">
224
<xsl:text>-</xsl:text>
227
<xsl:text>+</xsl:text>
231
<xsl:for-each select="* | text()[normalize-space(.) != '']">
232
<xsl:if test="position() != 1">
233
<xsl:value-of select="$joinchar"/>
236
<xsl:when test="./self::text()">
237
<xsl:value-of select="normalize-space(.)"/>
240
<xsl:apply-templates mode="mal2html.inline.mode" select="."/>
247
<xsl:template mode="mal2html.inline.mode" match="mal:link">
248
<xsl:call-template name="mal2html.span"/>
251
<!-- = link % mal2html.inline.content.mode = -->
252
<xsl:template mode="mal2html.inline.content.mode" match="mal:link">
254
<xsl:when test="normalize-space(.) != ''">
255
<xsl:apply-templates mode="mal2html.inline.mode"/>
258
<xsl:call-template name="mal.link.content">
259
<xsl:with-param name="role" select="@role"/>
266
<xsl:template mode="mal2html.inline.mode" match="mal:output">
267
<xsl:variable name="style" select="concat(' ', @style, ' ')"/>
268
<xsl:call-template name="mal2html.span">
269
<xsl:with-param name="class">
271
<xsl:when test="contains($style, ' error ')">
272
<xsl:text>error</xsl:text>
274
<xsl:when test="contains($style, ' prompt ')">
275
<xsl:text>prompt</xsl:text>
283
<xsl:template mode="mal2html.inline.mode" match="mal:span">
284
<xsl:call-template name="mal2html.span"/>
288
<xsl:template mode="mal2html.inline.mode" match="mal:sys">
289
<xsl:call-template name="mal2html.span"/>
293
<xsl:template mode="mal2html.inline.mode" match="mal:var">
294
<xsl:call-template name="mal2html.span"/>
298
<xsl:template mode="mal2html.inline.mode" match="text()">
299
<xsl:value-of select="."/>