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