~ubuntu-branches/ubuntu/utopic/yelp-xsl/utopic

« back to all changes in this revision

Viewing changes to xslt/mallard/html/mal2html-inline.xsl

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2010-11-29 10:00:13 UTC
  • Revision ID: james.westby@ubuntu.com-20101129100013-1fxze8fm1fegxl8w
Tags: upstream-2.31.6
ImportĀ upstreamĀ versionĀ 2.31.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
 
2
<!--
 
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
 
6
later version.
 
7
 
 
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
 
11
details.
 
12
 
 
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
 
16
02111-1307, USA.
 
17
-->
 
18
 
 
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"
 
24
                version="1.0">
 
25
 
 
26
<!--!!==========================================================================
 
27
Mallard to HTML - Inlines
 
28
Handle simple Mallard block elements.
 
29
:Revision:version="1.0" date="2010-06-03" status="final"
 
30
 
 
31
This stylesheet contains templates to handle most Mallard inline elements.
 
32
-->
 
33
 
 
34
<xsl:template mode="mal.link.content.mode" match="*">
 
35
  <xsl:apply-templates mode="mal2html.inline.mode" select="."/>
 
36
</xsl:template>
 
37
 
 
38
 
 
39
<!--%%==========================================================================
 
40
mal2html.inline.mode
 
41
Process Mallard elements in inline mode.
 
42
:Revision:version="1.0" date="2010-06-03" status="final"
 
43
 
 
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.
 
48
 
 
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
 
53
elements.
 
54
-->
 
55
<xsl:template mode="mal2html.inline.mode" match="*">
 
56
  <xsl:message>
 
57
    <xsl:text>Unmatched inline element: </xsl:text>
 
58
    <xsl:value-of select="local-name(.)"/>
 
59
  </xsl:message>
 
60
  <xsl:apply-templates mode="mal2html.inline.mode"/>
 
61
</xsl:template>
 
62
 
 
63
 
 
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"
 
68
 
 
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
 
72
template.
 
73
-->
 
74
<xsl:template mode="mal2html.inline.content.mode" match="node()">
 
75
  <xsl:apply-templates mode="mal2html.inline.mode"/>
 
76
</xsl:template>
 
77
 
 
78
 
 
79
<!--**==========================================================================
 
80
mal2html.span
 
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.
 
85
 
 
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}.
 
90
 
 
91
This template automatically handles ubiquitous linking if ${node} contains
 
92
an #{xref} or #{href} attribute.
 
93
-->
 
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"/>
 
99
    <xsl:choose>
 
100
      <xsl:when test="$node/@xref | $node/@href">
 
101
        <a>
 
102
          <xsl:attribute name="href">
 
103
            <xsl:call-template name="mal.link.target">
 
104
              <xsl:with-param name="node" select="$node"/>
 
105
            </xsl:call-template>
 
106
          </xsl:attribute>
 
107
          <xsl:attribute name="title">
 
108
            <xsl:call-template name="mal.link.tooltip">
 
109
              <xsl:with-param name="node" select="$node"/>
 
110
            </xsl:call-template>
 
111
          </xsl:attribute>
 
112
          <xsl:apply-templates mode="mal2html.inline.content.mode" select="$node"/>
 
113
        </a>
 
114
      </xsl:when>
 
115
      <xsl:otherwise>
 
116
        <xsl:apply-templates mode="mal2html.inline.content.mode" select="$node"/>
 
117
      </xsl:otherwise>
 
118
    </xsl:choose>
 
119
  </span>
 
120
</xsl:template>
 
121
 
 
122
 
 
123
<!-- == Matched Templates == -->
 
124
 
 
125
<!-- = app = -->
 
126
<xsl:template mode="mal2html.inline.mode" match="mal:app">
 
127
  <xsl:call-template name="mal2html.span"/>
 
128
</xsl:template>
 
129
 
 
130
<!-- = cmd = -->
 
131
<xsl:template mode="mal2html.inline.mode" match="mal:cmd">
 
132
  <xsl:call-template name="mal2html.span"/>
 
133
</xsl:template>
 
134
 
 
135
<!-- = code = -->
 
136
<xsl:template mode="mal2html.inline.mode" match="mal:code">
 
137
  <xsl:call-template name="mal2html.span"/>
 
138
</xsl:template>
 
139
 
 
140
<!-- = date = -->
 
141
<xsl:template mode="mal2html.inline.mode" match="mal:date">
 
142
  <xsl:call-template name="mal2html.span"/>
 
143
</xsl:template>
 
144
 
 
145
<!-- = em = -->
 
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>
 
151
      </xsl:if>
 
152
    </xsl:with-param>
 
153
  </xsl:call-template>
 
154
</xsl:template>
 
155
 
 
156
<!-- = file = -->
 
157
<xsl:template mode="mal2html.inline.mode" match="mal:file">
 
158
  <xsl:call-template name="mal2html.span"/>
 
159
</xsl:template>
 
160
 
 
161
<!-- = gui = -->
 
162
<xsl:template mode="mal2html.inline.mode" match="mal:gui">
 
163
  <xsl:call-template name="mal2html.span"/>
 
164
</xsl:template>
 
165
 
 
166
<!-- = guiseq = -->
 
167
<xsl:template mode="mal2html.inline.mode" match="mal:guiseq">
 
168
  <xsl:call-template name="mal2html.span"/>
 
169
</xsl:template>
 
170
 
 
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"/>
 
177
      </xsl:call-template>
 
178
    </xsl:variable>
 
179
    <xsl:choose>
 
180
      <xsl:when test="$dir = 'rtl'">
 
181
        <xsl:text>&#x00A0;&#x25C2; </xsl:text>
 
182
      </xsl:when>
 
183
      <xsl:otherwise>
 
184
        <xsl:text>&#x00A0;&#x25B8; </xsl:text>
 
185
      </xsl:otherwise>
 
186
    </xsl:choose>
 
187
  </xsl:variable>
 
188
  <xsl:for-each select="mal:gui | text()[normalize-space(.) != '']">
 
189
    <xsl:if test="position() != 1">
 
190
      <xsl:value-of select="$arrow"/>
 
191
    </xsl:if>
 
192
    <xsl:apply-templates mode="mal2html.inline.mode" select="."/>
 
193
  </xsl:for-each>
 
194
</xsl:template>
 
195
 
 
196
<!-- = input = -->
 
197
<xsl:template mode="mal2html.inline.mode" match="mal:input">
 
198
  <xsl:call-template name="mal2html.span"/>
 
199
</xsl:template>
 
200
 
 
201
<!-- = hi = -->
 
202
<xsl:template mode="mal2html.inline.mode" match="e:hi">
 
203
  <xsl:call-template name="mal2html.span"/>
 
204
</xsl:template>
 
205
 
 
206
<!-- = key = -->
 
207
<xsl:template mode="mal2html.inline.mode" match="mal:key">
 
208
  <xsl:call-template name="mal2html.span"/>
 
209
</xsl:template>
 
210
 
 
211
<!-- = keyseq = -->
 
212
<xsl:template mode="mal2html.inline.mode" match="mal:keyseq">
 
213
  <xsl:call-template name="mal2html.span"/>
 
214
</xsl:template>
 
215
 
 
216
<!-- = keyseq % mal2html.inline.content.mode = -->
 
217
<xsl:template mode="mal2html.inline.content.mode" match="mal:keyseq">
 
218
  <xsl:variable name="joinchar">
 
219
    <xsl:choose>
 
220
      <xsl:when test="@type = 'sequence'">
 
221
        <xsl:text> </xsl:text>
 
222
      </xsl:when>
 
223
      <xsl:when test="contains(concat(' ', @style, ' '), ' hyphen ')">
 
224
        <xsl:text>-</xsl:text>
 
225
      </xsl:when>
 
226
      <xsl:otherwise>
 
227
        <xsl:text>+</xsl:text>
 
228
      </xsl:otherwise>
 
229
    </xsl:choose>
 
230
  </xsl:variable>
 
231
  <xsl:for-each select="* | text()[normalize-space(.) != '']">
 
232
    <xsl:if test="position() != 1">
 
233
      <xsl:value-of select="$joinchar"/>
 
234
    </xsl:if>
 
235
    <xsl:choose>
 
236
      <xsl:when test="./self::text()">
 
237
        <xsl:value-of select="normalize-space(.)"/>
 
238
      </xsl:when>
 
239
      <xsl:otherwise>
 
240
        <xsl:apply-templates mode="mal2html.inline.mode" select="."/>
 
241
      </xsl:otherwise>
 
242
    </xsl:choose>
 
243
  </xsl:for-each>
 
244
</xsl:template>
 
245
 
 
246
<!-- = link = -->
 
247
<xsl:template mode="mal2html.inline.mode" match="mal:link">
 
248
  <xsl:call-template name="mal2html.span"/>
 
249
</xsl:template>
 
250
 
 
251
<!-- = link % mal2html.inline.content.mode = -->
 
252
<xsl:template mode="mal2html.inline.content.mode" match="mal:link">
 
253
  <xsl:choose>
 
254
    <xsl:when test="normalize-space(.) != ''">
 
255
      <xsl:apply-templates mode="mal2html.inline.mode"/>
 
256
    </xsl:when>
 
257
    <xsl:otherwise>
 
258
      <xsl:call-template name="mal.link.content">
 
259
        <xsl:with-param name="role" select="@role"/>
 
260
      </xsl:call-template>
 
261
    </xsl:otherwise>
 
262
  </xsl:choose>
 
263
</xsl:template>
 
264
 
 
265
<!-- = output = -->
 
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">
 
270
      <xsl:choose>
 
271
        <xsl:when test="contains($style, ' error ')">
 
272
          <xsl:text>error</xsl:text>
 
273
        </xsl:when>
 
274
        <xsl:when test="contains($style, ' prompt ')">
 
275
          <xsl:text>prompt</xsl:text>
 
276
        </xsl:when>
 
277
      </xsl:choose>
 
278
    </xsl:with-param>
 
279
  </xsl:call-template>
 
280
</xsl:template>
 
281
 
 
282
<!-- = span = -->
 
283
<xsl:template mode="mal2html.inline.mode" match="mal:span">
 
284
  <xsl:call-template name="mal2html.span"/>
 
285
</xsl:template>
 
286
 
 
287
<!-- = sys = -->
 
288
<xsl:template mode="mal2html.inline.mode" match="mal:sys">
 
289
  <xsl:call-template name="mal2html.span"/>
 
290
</xsl:template>
 
291
 
 
292
<!-- = var = -->
 
293
<xsl:template mode="mal2html.inline.mode" match="mal:var">
 
294
  <xsl:call-template name="mal2html.span"/>
 
295
</xsl:template>
 
296
 
 
297
<!-- = text() = -->
 
298
<xsl:template mode="mal2html.inline.mode" match="text()">
 
299
  <xsl:value-of select="."/>
 
300
</xsl:template>
 
301
 
 
302
</xsl:stylesheet>