~ubuntu-branches/ubuntu/saucy/yelp-xsl/saucy

1 by Robert Ancell
Import upstream version 2.31.6
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/"
1.1.19 by Andreas Henriksson
Import upstream version 3.8.1
21
                xmlns:ui="http://projectmallard.org/ui/1.0/"
22
                xmlns:uix="http://projectmallard.org/experimental/ui/"
1.1.8 by Michael Terry
Import upstream version 3.1.2
23
                xmlns:str="http://exslt.org/strings"
1 by Robert Ancell
Import upstream version 2.31.6
24
                xmlns="http://www.w3.org/1999/xhtml"
1.1.19 by Andreas Henriksson
Import upstream version 3.8.1
25
                exclude-result-prefixes="mal ui uix str"
1 by Robert Ancell
Import upstream version 2.31.6
26
                version="1.0">
27
28
<!--!!==========================================================================
29
Mallard to HTML - Lists
30
Handle Mallard list elements.
31
:Revision: version="1.0" date="2010-06-04" status="final"
32
33
This stylesheet contains templates for the #{list}, #{steps}, #{terms}, and
34
#{tree} elements in %{mal2html.block.mode}. It handles the parent list elements,
35
as well as any special processing for child #{item} elements.
36
-->
37
38
<!-- = list = -->
39
<xsl:template mode="mal2html.block.mode" match="mal:list">
1.1.16 by Michael Terry
Import upstream version 3.3.3
40
  <xsl:variable name="if"><xsl:call-template name="mal.if.test"/></xsl:variable><xsl:if test="$if != ''">
1 by Robert Ancell
Import upstream version 2.31.6
41
  <xsl:variable name="style" select="concat(' ', @style, ' ')"/>
42
  <xsl:variable name="el">
43
    <xsl:choose>
44
      <xsl:when test="not(@type) or (@type = 'none') or (@type = 'box')
45
                      or (@type = 'check') or (@type = 'circle') or (@type = 'diamond')
46
                      or (@type = 'disc') or (@type = 'hyphen') or (@type = 'square')">
47
        <xsl:text>ul</xsl:text>
48
      </xsl:when>
49
      <xsl:otherwise>
50
        <xsl:text>ol</xsl:text>
51
      </xsl:otherwise>
52
    </xsl:choose>
53
  </xsl:variable>
1.1.9 by Jeremy Bicha
Import upstream version 3.1.3
54
  <div>
1 by Robert Ancell
Import upstream version 2.31.6
55
    <xsl:call-template name="html.lang.attrs"/>
1.1.9 by Jeremy Bicha
Import upstream version 3.1.3
56
    <xsl:attribute name="class">
57
      <xsl:text>list</xsl:text>
1.1.19 by Andreas Henriksson
Import upstream version 3.8.1
58
      <xsl:if test="mal:title and (@ui:expanded or @uix:expanded)">
1.1.9 by Jeremy Bicha
Import upstream version 3.1.3
59
        <xsl:text> ui-expander</xsl:text>
1 by Robert Ancell
Import upstream version 2.31.6
60
      </xsl:if>
1.1.16 by Michael Terry
Import upstream version 3.3.3
61
      <xsl:if test="$if != 'true'">
62
        <xsl:text> if-if </xsl:text>
63
        <xsl:value-of select="$if"/>
64
      </xsl:if>
1.1.9 by Jeremy Bicha
Import upstream version 3.1.3
65
    </xsl:attribute>
66
    <xsl:call-template name="mal2html.ui.expander.data"/>
67
    <div class="inner">
68
      <xsl:apply-templates mode="mal2html.block.mode" select="mal:title"/>
69
      <div class="region">
70
        <xsl:element name="{$el}" namespace="{$html.namespace}">
71
          <xsl:attribute name="class">
72
            <xsl:text>list</xsl:text>
73
            <xsl:if test="contains($style, ' compact ')">
74
              <xsl:text> compact</xsl:text>
75
            </xsl:if>
76
          </xsl:attribute>
77
          <xsl:if test="@type">
78
            <xsl:attribute name="style">
79
              <xsl:value-of select="concat('list-style-type:', @type)"/>
80
            </xsl:attribute>
81
          </xsl:if>
1.1.19 by Andreas Henriksson
Import upstream version 3.8.1
82
          <xsl:if test="contains(concat(' ', @style, ' '), ' continues ')">
83
            <xsl:attribute name="start">
84
              <xsl:call-template name="mal.list.start"/>
85
            </xsl:attribute>
86
          </xsl:if>
1.1.9 by Jeremy Bicha
Import upstream version 3.1.3
87
          <xsl:apply-templates select="mal:item"/>
88
        </xsl:element>
89
      </div>
90
    </div>
1 by Robert Ancell
Import upstream version 2.31.6
91
  </div>
1.1.8 by Michael Terry
Import upstream version 3.1.2
92
</xsl:if>
1 by Robert Ancell
Import upstream version 2.31.6
93
</xsl:template>
94
95
<!-- = list/item = -->
96
<xsl:template match="mal:list/mal:item">
1.1.16 by Michael Terry
Import upstream version 3.3.3
97
  <xsl:variable name="if"><xsl:call-template name="mal.if.test"/></xsl:variable><xsl:if test="$if != ''">
98
  <li>
99
    <xsl:attribute name="class">
100
      <xsl:text>list</xsl:text>
101
      <xsl:if test="$if != 'true'">
102
        <xsl:text> if-if </xsl:text>
103
        <xsl:value-of select="$if"/>
104
      </xsl:if>
105
    </xsl:attribute>
1 by Robert Ancell
Import upstream version 2.31.6
106
    <xsl:call-template name="html.lang.attrs"/>
107
    <xsl:apply-templates mode="mal2html.block.mode"/>
108
  </li>
1.1.8 by Michael Terry
Import upstream version 3.1.2
109
</xsl:if>
1 by Robert Ancell
Import upstream version 2.31.6
110
</xsl:template>
111
112
<!-- = steps = -->
113
<xsl:template mode="mal2html.block.mode" match="mal:steps">
1.1.16 by Michael Terry
Import upstream version 3.3.3
114
  <xsl:variable name="if"><xsl:call-template name="mal.if.test"/></xsl:variable><xsl:if test="$if != ''">
1.1.9 by Jeremy Bicha
Import upstream version 3.1.3
115
  <div>
1 by Robert Ancell
Import upstream version 2.31.6
116
    <xsl:call-template name="html.lang.attrs"/>
1.1.9 by Jeremy Bicha
Import upstream version 3.1.3
117
    <xsl:attribute name="class">
118
      <xsl:text>steps</xsl:text>
1.1.19 by Andreas Henriksson
Import upstream version 3.8.1
119
      <xsl:if test="mal:title and (@ui:expanded or @uix:expanded)">
1.1.9 by Jeremy Bicha
Import upstream version 3.1.3
120
        <xsl:text> ui-expander</xsl:text>
121
      </xsl:if>
1.1.16 by Michael Terry
Import upstream version 3.3.3
122
      <xsl:if test="$if != 'true'">
123
        <xsl:text> if-if </xsl:text>
124
        <xsl:value-of select="$if"/>
125
      </xsl:if>
1.1.9 by Jeremy Bicha
Import upstream version 3.1.3
126
    </xsl:attribute>
127
    <xsl:call-template name="mal2html.ui.expander.data"/>
128
    <div class="inner">
129
      <xsl:apply-templates mode="mal2html.block.mode" select="mal:title"/>
130
      <div class="region">
131
        <ol class="steps">
1.1.19 by Andreas Henriksson
Import upstream version 3.8.1
132
          <xsl:if test="contains(concat(' ', @style, ' '), ' continues ')">
133
            <xsl:attribute name="start">
134
              <xsl:call-template name="mal.list.start"/>
135
            </xsl:attribute>
136
          </xsl:if>
1.1.9 by Jeremy Bicha
Import upstream version 3.1.3
137
          <xsl:apply-templates select="mal:item"/>
138
        </ol>
139
      </div>
140
    </div>
1 by Robert Ancell
Import upstream version 2.31.6
141
  </div>
1.1.8 by Michael Terry
Import upstream version 3.1.2
142
</xsl:if>
1 by Robert Ancell
Import upstream version 2.31.6
143
</xsl:template>
144
1.1.19 by Andreas Henriksson
Import upstream version 3.8.1
145
<xsl:template name="mal.list.start">
146
  <xsl:param name="node" select="."/>
147
  <xsl:choose>
148
    <xsl:when test="contains(concat(' ', $node/@style, ' '), ' continues ')">
149
      <xsl:variable name="prevlist"
150
                    select="$node/preceding::*[name(.) = name($node)]
151
                            [not(@type) and not($node/@type) or (@type = $node/@type)][1]"/>
152
      <xsl:choose>
153
        <xsl:when test="count($prevlist) = 0">1</xsl:when>
154
        <xsl:otherwise>
155
          <xsl:variable name="prevlength" select="count($prevlist/mal:item)"/>
156
          <xsl:variable name="prevstart">
157
            <xsl:call-template name="mal.list.start">
158
              <xsl:with-param name="node" select="$prevlist"/>
159
            </xsl:call-template>
160
          </xsl:variable>
161
          <xsl:value-of select="$prevstart + $prevlength"/>
162
        </xsl:otherwise>
163
      </xsl:choose>
164
    </xsl:when>
165
    <xsl:otherwise>
166
      <xsl:text>1</xsl:text>
167
    </xsl:otherwise>
168
  </xsl:choose>
169
</xsl:template>
170
1 by Robert Ancell
Import upstream version 2.31.6
171
<!-- = steps/item = -->
172
<xsl:template match="mal:steps/mal:item">
1.1.16 by Michael Terry
Import upstream version 3.3.3
173
  <xsl:variable name="if"><xsl:call-template name="mal.if.test"/></xsl:variable><xsl:if test="$if != ''">
174
  <li>
175
    <xsl:attribute name="class">
176
      <xsl:text>steps</xsl:text>
177
      <xsl:if test="$if != 'true'">
178
        <xsl:text> if-if </xsl:text>
179
        <xsl:value-of select="$if"/>
180
      </xsl:if>
181
    </xsl:attribute>
1 by Robert Ancell
Import upstream version 2.31.6
182
    <xsl:call-template name="html.lang.attrs"/>
183
    <xsl:apply-templates mode="mal2html.block.mode"/>
184
  </li>
1.1.8 by Michael Terry
Import upstream version 3.1.2
185
</xsl:if>
1 by Robert Ancell
Import upstream version 2.31.6
186
</xsl:template>
187
188
<!-- = terms = -->
189
<xsl:template mode="mal2html.block.mode" match="mal:terms">
1.1.16 by Michael Terry
Import upstream version 3.3.3
190
  <xsl:variable name="if"><xsl:call-template name="mal.if.test"/></xsl:variable><xsl:if test="$if != ''">
1 by Robert Ancell
Import upstream version 2.31.6
191
  <xsl:variable name="style" select="concat(' ', @style, ' ')"/>
1.1.9 by Jeremy Bicha
Import upstream version 3.1.3
192
  <div>
1 by Robert Ancell
Import upstream version 2.31.6
193
    <xsl:call-template name="html.lang.attrs"/>
1.1.9 by Jeremy Bicha
Import upstream version 3.1.3
194
    <xsl:attribute name="class">
195
      <xsl:text>terms</xsl:text>
1.1.19 by Andreas Henriksson
Import upstream version 3.8.1
196
      <xsl:if test="mal:title and (@ui:expanded or @uix:expanded)">
1.1.9 by Jeremy Bicha
Import upstream version 3.1.3
197
        <xsl:text> ui-expander</xsl:text>
198
      </xsl:if>
1.1.16 by Michael Terry
Import upstream version 3.3.3
199
      <xsl:if test="$if != 'true'">
200
        <xsl:text> if-if </xsl:text>
201
        <xsl:value-of select="$if"/>
202
      </xsl:if>
1.1.9 by Jeremy Bicha
Import upstream version 3.1.3
203
    </xsl:attribute>
204
    <xsl:call-template name="mal2html.ui.expander.data"/>
205
    <div class="inner">
206
      <xsl:apply-templates mode="mal2html.block.mode" select="mal:title"/>
207
      <div class="region">
208
        <dl class="terms">
209
          <xsl:attribute name="class">
210
            <xsl:text>terms</xsl:text>
211
            <xsl:if test="contains($style, ' compact ')">
212
              <xsl:text> compact</xsl:text>
213
            </xsl:if>
214
          </xsl:attribute>
215
          <xsl:apply-templates select="mal:item"/>
216
        </dl>
217
      </div>
218
    </div>
1 by Robert Ancell
Import upstream version 2.31.6
219
  </div>
1.1.8 by Michael Terry
Import upstream version 3.1.2
220
</xsl:if>
1 by Robert Ancell
Import upstream version 2.31.6
221
</xsl:template>
222
223
<!-- = terms/item = -->
224
<xsl:template match="mal:terms/mal:item">
1.1.16 by Michael Terry
Import upstream version 3.3.3
225
  <xsl:variable name="if"><xsl:call-template name="mal.if.test"/></xsl:variable><xsl:if test="$if != ''">
1 by Robert Ancell
Import upstream version 2.31.6
226
  <xsl:for-each select="mal:title">
1.1.16 by Michael Terry
Import upstream version 3.3.3
227
    <dt>
228
      <xsl:attribute name="class">
229
        <xsl:text>terms</xsl:text>
230
        <xsl:if test="$if != 'true'">
231
          <xsl:text> if-if </xsl:text>
232
          <xsl:value-of select="$if"/>
233
        </xsl:if>
234
      </xsl:attribute>
1 by Robert Ancell
Import upstream version 2.31.6
235
      <xsl:call-template name="html.lang.attrs">
236
        <xsl:with-param name="parent" select=".."/>
237
      </xsl:call-template>
238
      <xsl:apply-templates mode="mal2html.inline.mode"/>
239
    </dt>
240
  </xsl:for-each>
1.1.16 by Michael Terry
Import upstream version 3.3.3
241
  <dd>
242
    <xsl:attribute name="class">
243
      <xsl:text>terms</xsl:text>
244
      <xsl:if test="$if != 'true'">
245
        <xsl:text> if-if </xsl:text>
246
        <xsl:value-of select="$if"/>
247
      </xsl:if>
248
    </xsl:attribute>
1 by Robert Ancell
Import upstream version 2.31.6
249
    <xsl:call-template name="html.lang.attrs"/>
250
    <xsl:apply-templates mode="mal2html.block.mode" select="*[not(self::mal:title)]"/>
251
  </dd>
1.1.8 by Michael Terry
Import upstream version 3.1.2
252
</xsl:if>
1 by Robert Ancell
Import upstream version 2.31.6
253
</xsl:template>
254
255
<!-- = tree = -->
256
<xsl:template mode="mal2html.block.mode" match="mal:tree">
1.1.16 by Michael Terry
Import upstream version 3.3.3
257
  <xsl:variable name="if"><xsl:call-template name="mal.if.test"/></xsl:variable><xsl:if test="$if != ''">
1 by Robert Ancell
Import upstream version 2.31.6
258
  <xsl:variable name="lines" select="contains(concat(' ', @style, ' '), ' lines ')"/>
259
  <div>
260
    <xsl:call-template name="html.lang.attrs"/>
261
    <xsl:attribute name="class">
262
      <xsl:text>tree</xsl:text>
263
      <xsl:if test="$lines">
264
        <xsl:text> tree-lines</xsl:text>
265
      </xsl:if>
1.1.19 by Andreas Henriksson
Import upstream version 3.8.1
266
      <xsl:if test="mal:title and (@ui:expanded or @uix:expanded)">
1.1.9 by Jeremy Bicha
Import upstream version 3.1.3
267
        <xsl:text> ui-expander</xsl:text>
268
      </xsl:if>
1.1.16 by Michael Terry
Import upstream version 3.3.3
269
      <xsl:if test="$if != 'true'">
270
        <xsl:text> if-if </xsl:text>
271
        <xsl:value-of select="$if"/>
272
      </xsl:if>
1 by Robert Ancell
Import upstream version 2.31.6
273
    </xsl:attribute>
1.1.9 by Jeremy Bicha
Import upstream version 3.1.3
274
    <xsl:call-template name="mal2html.ui.expander.data"/>
275
    <div class="inner">
276
      <xsl:apply-templates mode="mal2html.block.mode" select="mal:title"/>
277
      <div class="region">
278
        <ul class="tree">
279
          <xsl:apply-templates mode="mal2html.tree.mode" select="mal:item">
280
            <xsl:with-param name="lines" select="$lines"/>
281
          </xsl:apply-templates>
282
        </ul>
283
      </div>
284
    </div>
1 by Robert Ancell
Import upstream version 2.31.6
285
  </div>
1.1.8 by Michael Terry
Import upstream version 3.1.2
286
</xsl:if>
1 by Robert Ancell
Import upstream version 2.31.6
287
</xsl:template>
288
289
<!--%%==========================================================================
290
mal2html.tree.mode
291
Process an #{item} element inside a #{tree}.
292
:Revision: version="1.0" date="2010-06-04" status="final"
293
$lines: Whether to draw lines indicating hierarchy.
294
$prefix: The line markers used by the parent #{item}.
295
296
This mode is used for processing #{item} elements in #{tree} elements. It is
297
applied by the template for #{tree} and recursively calls itself. If the parent
298
#{tree} has the style hint #{"lines"}, the ${lines} parameter will be #{true}.
299
In this case, this template calculates a prefix based on its position and
300
neighboring #{item} elements, and passes that prefix to child elements.
301
-->
302
<xsl:template mode="mal2html.tree.mode" match="mal:item">
303
  <xsl:param name="lines" select="false()"/>
304
  <xsl:param name="prefix" select="''"/>
1.1.8 by Michael Terry
Import upstream version 3.1.2
305
  <xsl:variable name="if">
306
    <xsl:choose>
307
      <!-- We do the tests as we process children, to get lines right, and
308
           only apply-templates to what we have to. So if this is a deep
309
           item, don't spend the CPU cycles testing it again.
310
      -->
311
      <xsl:when test="parent::mal:item">
312
        <xsl:text>true</xsl:text>
313
      </xsl:when>
314
      <xsl:otherwise>
315
        <xsl:call-template name="mal.if.test"/>
316
      </xsl:otherwise>
317
    </xsl:choose>
318
  </xsl:variable>
1.1.16 by Michael Terry
Import upstream version 3.3.3
319
  <xsl:if test="$if != ''">
320
  <li>
321
    <xsl:attribute name="class">
322
      <xsl:text>tree</xsl:text>
323
      <xsl:if test="$if != 'true'">
324
        <xsl:text> if-if </xsl:text>
325
        <xsl:value-of select="$if"/>
326
      </xsl:if>
327
    </xsl:attribute>
1 by Robert Ancell
Import upstream version 2.31.6
328
    <xsl:call-template name="html.lang.attrs"/>
329
    <div>
330
      <xsl:if test="$lines">
331
        <xsl:value-of select="$prefix"/>
332
        <xsl:text> </xsl:text>
333
      </xsl:if>
334
      <xsl:apply-templates mode="mal2html.inline.mode"
335
                           select="node()[not(self::mal:item)]"/>
336
    </div>
1.1.8 by Michael Terry
Import upstream version 3.1.2
337
    <xsl:variable name="items">
338
      <xsl:for-each select="mal:item">
339
        <xsl:variable name="itemif">
340
          <xsl:call-template name="mal.if.test"/>
341
        </xsl:variable>
342
        <xsl:if test="$itemif = 'true'">
343
          <xsl:value-of select="concat(position(), ':')"/>
344
        </xsl:if>
345
      </xsl:for-each>
346
    </xsl:variable>
347
    <xsl:if test="$items != ''">
1 by Robert Ancell
Import upstream version 2.31.6
348
      <ul class="tree">
1.1.8 by Michael Terry
Import upstream version 3.1.2
349
        <xsl:variable name="node" select="."/>
350
        <xsl:for-each select="str:split($items, ':')">
351
          <xsl:variable name="itempos" select="number(.)"/>
352
          <xsl:variable name="item" select="$node/mal:item[position() = $itempos]"/>
353
          <xsl:apply-templates mode="mal2html.tree.mode" select="$item">
1 by Robert Ancell
Import upstream version 2.31.6
354
            <xsl:with-param name="lines" select="$lines"/>
355
            <xsl:with-param name="prefix">
356
              <xsl:if test="$lines">
357
                <xsl:variable name="dir">
358
                  <xsl:call-template name="l10n.direction">
1.1.8 by Michael Terry
Import upstream version 3.1.2
359
                    <xsl:with-param name="lang" select="$item/ancestor-or-self::*[@xml:lang][1]/@xml:lang"/>
1 by Robert Ancell
Import upstream version 2.31.6
360
                  </xsl:call-template>
361
                </xsl:variable>
362
                <xsl:value-of select="translate(translate(translate(translate(
363
                                      $prefix,
364
                                      '&#x251C;', '&#x2502;'),
365
                                      '&#x2524;', '&#x2502;'),
366
                                      '&#x2514;', '&#x202F;'),
367
                                      '&#x2518;', '&#x202F;')"/>
368
                <xsl:text>&#x202F;&#x202F;&#x202F;&#x202F;</xsl:text>
369
                <xsl:choose>
1.1.8 by Michael Terry
Import upstream version 3.1.2
370
                  <xsl:when test="position() != last()">
1 by Robert Ancell
Import upstream version 2.31.6
371
                    <xsl:choose>
372
                      <xsl:when test="$dir = 'rtl'">
373
                        <xsl:text>&#x2524;</xsl:text>
374
                      </xsl:when>
375
                      <xsl:otherwise>
376
                        <xsl:text>&#x251C;</xsl:text>
377
                      </xsl:otherwise>
378
                    </xsl:choose>
379
                  </xsl:when>
380
                  <xsl:otherwise>
381
                    <xsl:choose>
382
                      <xsl:when test="$dir = 'rtl'">
383
                        <xsl:text>&#x2518;</xsl:text>
384
                      </xsl:when>
385
                      <xsl:otherwise>
386
                        <xsl:text>&#x2514;</xsl:text>
387
                      </xsl:otherwise>
388
                    </xsl:choose>
389
                  </xsl:otherwise>
390
                </xsl:choose>
391
              </xsl:if>
392
            </xsl:with-param>
393
          </xsl:apply-templates>
394
        </xsl:for-each>
395
      </ul>
396
    </xsl:if>
397
  </li>
1.1.8 by Michael Terry
Import upstream version 3.1.2
398
  </xsl:if>
1 by Robert Ancell
Import upstream version 2.31.6
399
</xsl:template>
400
401
</xsl:stylesheet>