~ubuntu-branches/ubuntu/trusty/yelp-xsl/trusty

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Michael Terry
  • Date: 2011-07-09 10:02:21 UTC
  • mto: (11.1.1 experimental) (1.3.1)
  • mto: This revision was merged to the branch mainline in revision 13.
  • Revision ID: james.westby@ubuntu.com-20110709100221-27hsncxrd63leyx4
Tags: upstream-3.1.2
ImportĀ upstreamĀ versionĀ 3.1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
20
20
                xmlns:mal="http://projectmallard.org/1.0/"
 
21
                xmlns:str="http://exslt.org/strings"
21
22
                xmlns="http://www.w3.org/1999/xhtml"
22
 
                exclude-result-prefixes="mal"
 
23
                exclude-result-prefixes="mal str"
23
24
                version="1.0">
24
25
 
25
26
<!--!!==========================================================================
34
35
 
35
36
<!-- = list = -->
36
37
<xsl:template mode="mal2html.block.mode" match="mal:list">
 
38
  <xsl:variable name="if"><xsl:call-template name="mal.if.test"/></xsl:variable><xsl:if test="$if = 'true'">
37
39
  <xsl:variable name="style" select="concat(' ', @style, ' ')"/>
38
40
  <xsl:variable name="el">
39
41
    <xsl:choose>
65
67
      <xsl:apply-templates select="mal:item"/>
66
68
    </xsl:element>
67
69
  </div>
 
70
</xsl:if>
68
71
</xsl:template>
69
72
 
70
73
<!-- = list/item = -->
71
74
<xsl:template match="mal:list/mal:item">
 
75
  <xsl:variable name="if"><xsl:call-template name="mal.if.test"/></xsl:variable><xsl:if test="$if = 'true'">
72
76
  <li class="list">
73
77
    <xsl:call-template name="html.lang.attrs"/>
74
78
    <xsl:apply-templates mode="mal2html.block.mode"/>
75
79
  </li>
 
80
</xsl:if>
76
81
</xsl:template>
77
82
 
78
83
<!-- = steps = -->
79
84
<xsl:template mode="mal2html.block.mode" match="mal:steps">
 
85
  <xsl:variable name="if"><xsl:call-template name="mal.if.test"/></xsl:variable><xsl:if test="$if = 'true'">
80
86
  <div class="steps">
81
87
    <xsl:call-template name="html.lang.attrs"/>
82
88
    <xsl:apply-templates mode="mal2html.block.mode" select="mal:title"/>
84
90
      <xsl:apply-templates select="mal:item"/>
85
91
    </ol>
86
92
  </div>
 
93
</xsl:if>
87
94
</xsl:template>
88
95
 
89
96
<!-- = steps/item = -->
90
97
<xsl:template match="mal:steps/mal:item">
 
98
  <xsl:variable name="if"><xsl:call-template name="mal.if.test"/></xsl:variable><xsl:if test="$if = 'true'">
91
99
  <li class="steps">
92
100
    <xsl:call-template name="html.lang.attrs"/>
93
101
    <xsl:apply-templates mode="mal2html.block.mode"/>
94
102
  </li>
 
103
</xsl:if>
95
104
</xsl:template>
96
105
 
97
106
<!-- = terms = -->
98
107
<xsl:template mode="mal2html.block.mode" match="mal:terms">
 
108
  <xsl:variable name="if"><xsl:call-template name="mal.if.test"/></xsl:variable><xsl:if test="$if = 'true'">
99
109
  <xsl:variable name="style" select="concat(' ', @style, ' ')"/>
100
110
  <div class="terms">
101
111
    <xsl:call-template name="html.lang.attrs"/>
110
120
      <xsl:apply-templates select="mal:item"/>
111
121
    </dl>
112
122
  </div>
 
123
</xsl:if>
113
124
</xsl:template>
114
125
 
115
126
<!-- = terms/item = -->
116
127
<xsl:template match="mal:terms/mal:item">
 
128
  <xsl:variable name="if"><xsl:call-template name="mal.if.test"/></xsl:variable><xsl:if test="$if = 'true'">
117
129
  <xsl:for-each select="mal:title">
118
130
    <dt class="terms">
119
131
      <xsl:call-template name="html.lang.attrs">
126
138
    <xsl:call-template name="html.lang.attrs"/>
127
139
    <xsl:apply-templates mode="mal2html.block.mode" select="*[not(self::mal:title)]"/>
128
140
  </dd>
 
141
</xsl:if>
129
142
</xsl:template>
130
143
 
131
144
<!-- = tree = -->
132
145
<xsl:template mode="mal2html.block.mode" match="mal:tree">
 
146
  <xsl:variable name="if"><xsl:call-template name="mal.if.test"/></xsl:variable><xsl:if test="$if = 'true'">
133
147
  <xsl:variable name="lines" select="contains(concat(' ', @style, ' '), ' lines ')"/>
134
148
  <div>
135
149
    <xsl:call-template name="html.lang.attrs"/>
145
159
      </xsl:apply-templates>
146
160
    </ul>
147
161
  </div>
 
162
</xsl:if>
148
163
</xsl:template>
149
164
 
150
165
<!--%%==========================================================================
163
178
<xsl:template mode="mal2html.tree.mode" match="mal:item">
164
179
  <xsl:param name="lines" select="false()"/>
165
180
  <xsl:param name="prefix" select="''"/>
 
181
  <xsl:variable name="if">
 
182
    <xsl:choose>
 
183
      <!-- We do the tests as we process children, to get lines right, and
 
184
           only apply-templates to what we have to. So if this is a deep
 
185
           item, don't spend the CPU cycles testing it again.
 
186
      -->
 
187
      <xsl:when test="parent::mal:item">
 
188
        <xsl:text>true</xsl:text>
 
189
      </xsl:when>
 
190
      <xsl:otherwise>
 
191
        <xsl:call-template name="mal.if.test"/>
 
192
      </xsl:otherwise>
 
193
    </xsl:choose>
 
194
  </xsl:variable>
 
195
  <xsl:if test="$if = 'true'">
166
196
  <li class="tree">
167
197
    <xsl:call-template name="html.lang.attrs"/>
168
198
    <div>
173
203
      <xsl:apply-templates mode="mal2html.inline.mode"
174
204
                           select="node()[not(self::mal:item)]"/>
175
205
    </div>
176
 
    <xsl:if test="mal:item">
 
206
    <xsl:variable name="items">
 
207
      <xsl:for-each select="mal:item">
 
208
        <xsl:variable name="itemif">
 
209
          <xsl:call-template name="mal.if.test"/>
 
210
        </xsl:variable>
 
211
        <xsl:if test="$itemif = 'true'">
 
212
          <xsl:value-of select="concat(position(), ':')"/>
 
213
        </xsl:if>
 
214
      </xsl:for-each>
 
215
    </xsl:variable>
 
216
    <xsl:if test="$items != ''">
177
217
      <ul class="tree">
178
 
        <xsl:for-each select="mal:item">
179
 
          <xsl:apply-templates mode="mal2html.tree.mode" select=".">
 
218
        <xsl:variable name="node" select="."/>
 
219
        <xsl:for-each select="str:split($items, ':')">
 
220
          <xsl:variable name="itempos" select="number(.)"/>
 
221
          <xsl:variable name="item" select="$node/mal:item[position() = $itempos]"/>
 
222
          <xsl:apply-templates mode="mal2html.tree.mode" select="$item">
180
223
            <xsl:with-param name="lines" select="$lines"/>
181
224
            <xsl:with-param name="prefix">
182
225
              <xsl:if test="$lines">
183
226
                <xsl:variable name="dir">
184
227
                  <xsl:call-template name="l10n.direction">
185
 
                    <xsl:with-param name="lang" select="ancestor-or-self::*[@xml:lang][1]/@xml:lang"/>
 
228
                    <xsl:with-param name="lang" select="$item/ancestor-or-self::*[@xml:lang][1]/@xml:lang"/>
186
229
                  </xsl:call-template>
187
230
                </xsl:variable>
188
231
                <xsl:value-of select="translate(translate(translate(translate(
193
236
                                      '&#x2518;', '&#x202F;')"/>
194
237
                <xsl:text>&#x202F;&#x202F;&#x202F;&#x202F;</xsl:text>
195
238
                <xsl:choose>
196
 
                  <xsl:when test="following-sibling::mal:item">
 
239
                  <xsl:when test="position() != last()">
197
240
                    <xsl:choose>
198
241
                      <xsl:when test="$dir = 'rtl'">
199
242
                        <xsl:text>&#x2524;</xsl:text>
221
264
      </ul>
222
265
    </xsl:if>
223
266
  </li>
 
267
  </xsl:if>
224
268
</xsl:template>
225
269
 
226
270
</xsl:stylesheet>