| 1 |
<?xml version="1.0" encoding="utf-8"?> |
| 2 |
<!DOCTYPE xsl:stylesheet [ |
| 3 |
<!ENTITY % common.entities SYSTEM "../common/entities.ent"> |
| 4 |
%common.entities; |
| 5 |
]> |
| 6 |
<xsl:stylesheet |
| 7 |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 8 |
xmlns:d="http://docbook.org/ns/docbook" |
| 9 |
xmlns:exsl="http://exslt.org/common" |
| 10 |
xmlns="http://www.w3.org/1999/xhtml" |
| 11 |
xmlns:stbl="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.Table" |
| 12 |
xmlns:xtbl="xalan://com.nwalsh.xalan.Table" |
| 13 |
xmlns:lxslt="http://xml.apache.org/xslt" |
| 14 |
xmlns:ptbl="http://nwalsh.com/xslt/ext/xsltproc/python/Table" |
| 15 |
exclude-result-prefixes="exsl stbl xtbl lxslt ptbl d" |
| 16 |
version="1.0"> |
| 17 |
|
| 18 |
<!-- $I html5-element-mods.xsl,v 1.2 2011-09-18 17:47:28 bobs Exp $ --> |
| 19 |
|
| 20 |
<!--==============================================================--> |
| 21 |
<!-- DocBook XSL Parameter settings --> |
| 22 |
<!--==============================================================--> |
| 23 |
<!-- Set these to blank so can output special HTML5 empty DOCTYPE --> |
| 24 |
<xsl:param name="chunker.output.doctype-system" select="''"/> |
| 25 |
<xsl:param name="chunker.output.doctype-public" select="''"/> |
| 26 |
|
| 27 |
<xsl:param name="table.borders.with.css" select="1"/> |
| 28 |
<xsl:param name="html.ext">.xhtml</xsl:param> |
| 29 |
<xsl:param name="toc.list.type">ul</xsl:param> |
| 30 |
<xsl:param name="css.decoration" select="1"/> |
| 31 |
<xsl:param name="make.clean.html" select="1"/> |
| 32 |
<xsl:param name="generate.id.attributes" select="1"/> |
| 33 |
<xsl:variable name="div.element">section</xsl:variable> |
| 34 |
|
| 35 |
<!--==============================================================--> |
| 36 |
<!-- Customized templates --> |
| 37 |
<!--==============================================================--> |
| 38 |
|
| 39 |
<!-- HTML5: needs special doctype --> |
| 40 |
<xsl:template name="user.preroot"> |
| 41 |
<xsl:text disable-output-escaping="yes"><!DOCTYPE html></xsl:text> |
| 42 |
</xsl:template> |
| 43 |
|
| 44 |
<!-- HTML5: Replace HTML acronum with abbr for HTML 5 --> |
| 45 |
<xsl:template match="d:acronym"> |
| 46 |
<xsl:call-template name="inline.charseq"> |
| 47 |
<xsl:with-param name="wrapper-name">abbr</xsl:with-param> |
| 48 |
</xsl:call-template> |
| 49 |
</xsl:template> |
| 50 |
|
| 51 |
<!-- HTML5: replace border="0" with border="" --> |
| 52 |
<!-- HTML5: No @summary allowed --> |
| 53 |
<!-- HTML5: replace many table atts with CSS styles --> |
| 54 |
<xsl:template match="d:tgroup" name="tgroup"> |
| 55 |
<xsl:if test="not(@cols) or @cols = '' or string(number(@cols)) = 'NaN'"> |
| 56 |
<xsl:message terminate="yes"> |
| 57 |
<xsl:text>Error: CALS tables must specify the number of columns.</xsl:text> |
| 58 |
</xsl:message> |
| 59 |
</xsl:if> |
| 60 |
|
| 61 |
<xsl:variable name="summary"> |
| 62 |
<xsl:call-template name="pi.dbhtml_table-summary"/> |
| 63 |
</xsl:variable> |
| 64 |
|
| 65 |
<xsl:variable name="cellspacing"> |
| 66 |
<xsl:call-template name="pi.dbhtml_cellspacing"/> |
| 67 |
</xsl:variable> |
| 68 |
|
| 69 |
<xsl:variable name="cellpadding"> |
| 70 |
<xsl:call-template name="pi.dbhtml_cellpadding"/> |
| 71 |
</xsl:variable> |
| 72 |
|
| 73 |
<!-- First generate colgroup with attributes --> |
| 74 |
<xsl:variable name="colgroup.with.attributes"> |
| 75 |
<colgroup> |
| 76 |
<xsl:call-template name="generate.colgroup"> |
| 77 |
<xsl:with-param name="cols" select="@cols"/> |
| 78 |
</xsl:call-template> |
| 79 |
</colgroup> |
| 80 |
</xsl:variable> |
| 81 |
|
| 82 |
<!-- then modify colgroup attributes with extension --> |
| 83 |
<xsl:variable name="colgroup.with.extension"> |
| 84 |
<xsl:choose> |
| 85 |
<xsl:when test="$use.extensions != 0 |
| 86 |
and $tablecolumns.extension != 0"> |
| 87 |
<xsl:choose> |
| 88 |
<xsl:when test="function-available('stbl:adjustColumnWidths')"> |
| 89 |
<xsl:copy-of select="stbl:adjustColumnWidths($colgroup.with.attributes)"/> |
| 90 |
</xsl:when> |
| 91 |
<xsl:when test="function-available('xtbl:adjustColumnWidths')"> |
| 92 |
<xsl:copy-of select="xtbl:adjustColumnWidths($colgroup.with.attributes)"/> |
| 93 |
</xsl:when> |
| 94 |
<xsl:when test="function-available('ptbl:adjustColumnWidths')"> |
| 95 |
<xsl:copy-of select="ptbl:adjustColumnWidths($colgroup.with.attributes)"/> |
| 96 |
</xsl:when> |
| 97 |
<xsl:otherwise> |
| 98 |
<xsl:message terminate="yes"> |
| 99 |
<xsl:text>No adjustColumnWidths function available.</xsl:text> |
| 100 |
</xsl:message> |
| 101 |
</xsl:otherwise> |
| 102 |
</xsl:choose> |
| 103 |
</xsl:when> |
| 104 |
<xsl:otherwise> |
| 105 |
<xsl:copy-of select="$colgroup.with.attributes"/> |
| 106 |
</xsl:otherwise> |
| 107 |
</xsl:choose> |
| 108 |
</xsl:variable> |
| 109 |
|
| 110 |
<!-- Now convert to @style --> |
| 111 |
<xsl:variable name="colgroup"> |
| 112 |
<xsl:call-template name="colgroup.with.style"> |
| 113 |
<xsl:with-param name="colgroup" select="$colgroup.with.extension"/> |
| 114 |
</xsl:call-template> |
| 115 |
</xsl:variable> |
| 116 |
|
| 117 |
<xsl:variable name="explicit.table.width"> |
| 118 |
<xsl:call-template name="pi.dbhtml_table-width"> |
| 119 |
<xsl:with-param name="node" select=".."/> |
| 120 |
</xsl:call-template> |
| 121 |
</xsl:variable> |
| 122 |
|
| 123 |
<xsl:variable name="table.width.candidate"> |
| 124 |
<xsl:choose> |
| 125 |
<xsl:when test="$explicit.table.width != ''"> |
| 126 |
<xsl:value-of select="$explicit.table.width"/> |
| 127 |
</xsl:when> |
| 128 |
<xsl:when test="$default.table.width = ''"> |
| 129 |
<xsl:text>100%</xsl:text> |
| 130 |
</xsl:when> |
| 131 |
<xsl:otherwise> |
| 132 |
<xsl:value-of select="$default.table.width"/> |
| 133 |
</xsl:otherwise> |
| 134 |
</xsl:choose> |
| 135 |
</xsl:variable> |
| 136 |
|
| 137 |
|
| 138 |
<xsl:variable name="table.width"> |
| 139 |
<xsl:if test="$default.table.width != '' |
| 140 |
or $explicit.table.width != ''"> |
| 141 |
<xsl:choose> |
| 142 |
<xsl:when test="contains($table.width.candidate, '%')"> |
| 143 |
<xsl:value-of select="$table.width.candidate"/> |
| 144 |
</xsl:when> |
| 145 |
<xsl:when test="$use.extensions != 0 |
| 146 |
and $tablecolumns.extension != 0"> |
| 147 |
<xsl:choose> |
| 148 |
<xsl:when test="function-available('stbl:convertLength')"> |
| 149 |
<xsl:value-of select="stbl:convertLength($table.width.candidate)"/> |
| 150 |
</xsl:when> |
| 151 |
<xsl:when test="function-available('xtbl:convertLength')"> |
| 152 |
<xsl:value-of select="xtbl:convertLength($table.width.candidate)"/> |
| 153 |
</xsl:when> |
| 154 |
<xsl:otherwise> |
| 155 |
<xsl:message terminate="yes"> |
| 156 |
<xsl:text>No convertLength function available.</xsl:text> |
| 157 |
</xsl:message> |
| 158 |
</xsl:otherwise> |
| 159 |
</xsl:choose> |
| 160 |
</xsl:when> |
| 161 |
<xsl:otherwise> |
| 162 |
<xsl:value-of select="$table.width.candidate"/> |
| 163 |
</xsl:otherwise> |
| 164 |
</xsl:choose> |
| 165 |
</xsl:if> |
| 166 |
</xsl:variable> |
| 167 |
|
| 168 |
<!-- assemble a table @style --> |
| 169 |
<xsl:variable name="table.style"> |
| 170 |
|
| 171 |
<xsl:if test="$cellspacing != '' or $html.cellspacing != ''"> |
| 172 |
<xsl:text>cellspacing: </xsl:text> |
| 173 |
<xsl:choose> |
| 174 |
<xsl:when test="$cellspacing != ''"> |
| 175 |
<xsl:value-of select="$cellspacing"/> |
| 176 |
</xsl:when> |
| 177 |
<xsl:otherwise> |
| 178 |
<xsl:value-of select="$html.cellspacing"/> |
| 179 |
</xsl:otherwise> |
| 180 |
</xsl:choose> |
| 181 |
<xsl:text>; </xsl:text> |
| 182 |
</xsl:if> |
| 183 |
|
| 184 |
<xsl:if test="$cellpadding != '' or $html.cellpadding != ''"> |
| 185 |
<xsl:text>cellpadding: </xsl:text> |
| 186 |
<xsl:choose> |
| 187 |
<xsl:when test="$cellpadding != ''"> |
| 188 |
<xsl:value-of select="$cellpadding"/> |
| 189 |
</xsl:when> |
| 190 |
<xsl:otherwise> |
| 191 |
<xsl:value-of select="$html.cellpadding"/> |
| 192 |
</xsl:otherwise> |
| 193 |
</xsl:choose> |
| 194 |
<xsl:text>; </xsl:text> |
| 195 |
</xsl:if> |
| 196 |
|
| 197 |
<xsl:choose> |
| 198 |
<xsl:when test="string-length($table.width) != 0"> |
| 199 |
<xsl:text>width: </xsl:text> |
| 200 |
<xsl:value-of select="$table.width"/> |
| 201 |
<xsl:text>; </xsl:text> |
| 202 |
</xsl:when> |
| 203 |
<xsl:when test="../@pgwide=1 or local-name(.) = 'entrytbl'"> |
| 204 |
<xsl:text>width: 100%; </xsl:text> |
| 205 |
</xsl:when> |
| 206 |
<xsl:otherwise> |
| 207 |
</xsl:otherwise> |
| 208 |
</xsl:choose> |
| 209 |
|
| 210 |
<xsl:choose> |
| 211 |
<xsl:when test="../@frame='all' or (not(../@frame) and $default.table.frame='all')"> |
| 212 |
<xsl:text>border-collapse: collapse; </xsl:text> |
| 213 |
<xsl:call-template name="border"> |
| 214 |
<xsl:with-param name="side" select="'top'"/> |
| 215 |
<xsl:with-param name="style" select="$table.frame.border.style"/> |
| 216 |
<xsl:with-param name="color" select="$table.frame.border.color"/> |
| 217 |
<xsl:with-param name="thickness" select="$table.frame.border.thickness"/> |
| 218 |
</xsl:call-template> |
| 219 |
<xsl:call-template name="border"> |
| 220 |
<xsl:with-param name="side" select="'bottom'"/> |
| 221 |
<xsl:with-param name="style" select="$table.frame.border.style"/> |
| 222 |
<xsl:with-param name="color" select="$table.frame.border.color"/> |
| 223 |
<xsl:with-param name="thickness" select="$table.frame.border.thickness"/> |
| 224 |
</xsl:call-template> |
| 225 |
<xsl:call-template name="border"> |
| 226 |
<xsl:with-param name="side" select="'left'"/> |
| 227 |
<xsl:with-param name="style" select="$table.frame.border.style"/> |
| 228 |
<xsl:with-param name="color" select="$table.frame.border.color"/> |
| 229 |
<xsl:with-param name="thickness" select="$table.frame.border.thickness"/> |
| 230 |
</xsl:call-template> |
| 231 |
<xsl:call-template name="border"> |
| 232 |
<xsl:with-param name="side" select="'right'"/> |
| 233 |
<xsl:with-param name="style" select="$table.frame.border.style"/> |
| 234 |
<xsl:with-param name="color" select="$table.frame.border.color"/> |
| 235 |
<xsl:with-param name="thickness" select="$table.frame.border.thickness"/> |
| 236 |
</xsl:call-template> |
| 237 |
</xsl:when> |
| 238 |
<xsl:when test="../@frame='topbot' or (not(../@frame) and $default.table.frame='topbot')"> |
| 239 |
<xsl:text>border-collapse: collapse;</xsl:text> |
| 240 |
<xsl:call-template name="border"> |
| 241 |
<xsl:with-param name="side" select="'top'"/> |
| 242 |
<xsl:with-param name="style" select="$table.frame.border.style"/> |
| 243 |
<xsl:with-param name="color" select="$table.frame.border.color"/> |
| 244 |
<xsl:with-param name="thickness" select="$table.frame.border.thickness"/> |
| 245 |
</xsl:call-template> |
| 246 |
<xsl:call-template name="border"> |
| 247 |
<xsl:with-param name="side" select="'bottom'"/> |
| 248 |
<xsl:with-param name="style" select="$table.frame.border.style"/> |
| 249 |
<xsl:with-param name="color" select="$table.frame.border.color"/> |
| 250 |
<xsl:with-param name="thickness" select="$table.frame.border.thickness"/> |
| 251 |
</xsl:call-template> |
| 252 |
</xsl:when> |
| 253 |
<xsl:when test="../@frame='top' or (not(../@frame) and $default.table.frame='top')"> |
| 254 |
<xsl:text>border-collapse: collapse;</xsl:text> |
| 255 |
<xsl:call-template name="border"> |
| 256 |
<xsl:with-param name="side" select="'top'"/> |
| 257 |
<xsl:with-param name="style" select="$table.frame.border.style"/> |
| 258 |
<xsl:with-param name="color" select="$table.frame.border.color"/> |
| 259 |
<xsl:with-param name="thickness" select="$table.frame.border.thickness"/> |
| 260 |
</xsl:call-template> |
| 261 |
</xsl:when> |
| 262 |
<xsl:when test="../@frame='bottom' or (not(../@frame) and $default.table.frame='bottom')"> |
| 263 |
<xsl:text>border-collapse: collapse;</xsl:text> |
| 264 |
<xsl:call-template name="border"> |
| 265 |
<xsl:with-param name="side" select="'bottom'"/> |
| 266 |
<xsl:with-param name="style" select="$table.frame.border.style"/> |
| 267 |
<xsl:with-param name="color" select="$table.frame.border.color"/> |
| 268 |
<xsl:with-param name="thickness" select="$table.frame.border.thickness"/> |
| 269 |
</xsl:call-template> |
| 270 |
</xsl:when> |
| 271 |
<xsl:when test="../@frame='sides' or (not(../@frame) and $default.table.frame='sides')"> |
| 272 |
<xsl:text>border-collapse: collapse;</xsl:text> |
| 273 |
<xsl:call-template name="border"> |
| 274 |
<xsl:with-param name="side" select="'left'"/> |
| 275 |
<xsl:with-param name="style" select="$table.frame.border.style"/> |
| 276 |
<xsl:with-param name="color" select="$table.frame.border.color"/> |
| 277 |
<xsl:with-param name="thickness" select="$table.frame.border.thickness"/> |
| 278 |
</xsl:call-template> |
| 279 |
<xsl:call-template name="border"> |
| 280 |
<xsl:with-param name="side" select="'right'"/> |
| 281 |
<xsl:with-param name="style" select="$table.frame.border.style"/> |
| 282 |
<xsl:with-param name="color" select="$table.frame.border.color"/> |
| 283 |
<xsl:with-param name="thickness" select="$table.frame.border.thickness"/> |
| 284 |
</xsl:call-template> |
| 285 |
</xsl:when> |
| 286 |
<xsl:when test="../@frame='none'"> |
| 287 |
<xsl:text>border: none;</xsl:text> |
| 288 |
</xsl:when> |
| 289 |
<xsl:otherwise> |
| 290 |
<xsl:text>border-collapse: collapse;</xsl:text> |
| 291 |
</xsl:otherwise> |
| 292 |
</xsl:choose> |
| 293 |
</xsl:variable> |
| 294 |
|
| 295 |
<table> |
| 296 |
<!-- HTML5: no table summary allowed --> |
| 297 |
<xsl:if test="string-length($table.style) != 0"> |
| 298 |
<xsl:attribute name="style"> |
| 299 |
<xsl:value-of select="$table.style"/> |
| 300 |
</xsl:attribute> |
| 301 |
</xsl:if> |
| 302 |
|
| 303 |
|
| 304 |
<xsl:copy-of select="$colgroup"/> |
| 305 |
|
| 306 |
<xsl:apply-templates select="d:thead"/> |
| 307 |
<xsl:apply-templates select="d:tfoot"/> |
| 308 |
<xsl:apply-templates select="d:tbody"/> |
| 309 |
|
| 310 |
<xsl:if test=".//d:footnote|../d:title//d:footnote"> |
| 311 |
<tbody class="footnotes"> |
| 312 |
<tr> |
| 313 |
<td colspan="{@cols}"> |
| 314 |
<xsl:apply-templates select=".//d:footnote|../d:title//d:footnote" mode="table.footnote.mode"/> |
| 315 |
</td> |
| 316 |
</tr> |
| 317 |
</tbody> |
| 318 |
</xsl:if> |
| 319 |
</table> |
| 320 |
</xsl:template> |
| 321 |
|
| 322 |
<!-- HTML5: convert col attributes to col CSS styles --> |
| 323 |
<xsl:template name="colgroup.with.style"> |
| 324 |
<xsl:param name="colgroup"/> |
| 325 |
|
| 326 |
<xsl:variable name="colgroup.nodeset" select="exsl:node-set($colgroup)"/> |
| 327 |
<xsl:apply-templates select="$colgroup.nodeset" mode="convert.to.style"/> |
| 328 |
</xsl:template> |
| 329 |
|
| 330 |
<xsl:template match="d:colgroup" mode="convert.to.style"> |
| 331 |
<xsl:copy> |
| 332 |
<xsl:copy-of select="@*"/> |
| 333 |
<xsl:apply-templates mode="convert.to.style"/> |
| 334 |
</xsl:copy> |
| 335 |
</xsl:template> |
| 336 |
|
| 337 |
<!-- HTML5: converts obsolete HTML attributes to CSS styles --> |
| 338 |
<xsl:template match="*" mode="convert.to.style"> |
| 339 |
|
| 340 |
<xsl:variable name="element" select="local-name(.)"/> |
| 341 |
|
| 342 |
<xsl:variable name="style.from.atts"> |
| 343 |
<xsl:for-each select="@*"> |
| 344 |
|
| 345 |
<xsl:choose> |
| 346 |
<!-- width and height attributes are ok for img element --> |
| 347 |
<xsl:when test="local-name() = 'width' and $element != 'img'"> |
| 348 |
<xsl:variable name="attvalue" select="normalize-space(.)"/> |
| 349 |
<xsl:text>width: </xsl:text> |
| 350 |
<xsl:value-of select="$attvalue"/> |
| 351 |
<!-- if integer value, add px unit --> |
| 352 |
<xsl:if test="floor($attvalue) = $attvalue"> |
| 353 |
<xsl:text>px</xsl:text> |
| 354 |
</xsl:if> |
| 355 |
<xsl:text>; </xsl:text> |
| 356 |
</xsl:when> |
| 357 |
|
| 358 |
<xsl:when test="local-name() = 'height' and $element != 'img'"> |
| 359 |
<xsl:variable name="attvalue" select="normalize-space(.)"/> |
| 360 |
<xsl:text>height: </xsl:text> |
| 361 |
<xsl:value-of select="$attvalue"/> |
| 362 |
<!-- if integer value, add px unit --> |
| 363 |
<xsl:if test="floor($attvalue) = $attvalue"> |
| 364 |
<xsl:text>px</xsl:text> |
| 365 |
</xsl:if> |
| 366 |
<xsl:text>; </xsl:text> |
| 367 |
</xsl:when> |
| 368 |
|
| 369 |
<xsl:when test="local-name() = 'align'"> |
| 370 |
<xsl:text>text-align: </xsl:text> |
| 371 |
<xsl:value-of select="."/> |
| 372 |
<xsl:text>; </xsl:text> |
| 373 |
</xsl:when> |
| 374 |
|
| 375 |
<xsl:when test="local-name() = 'valign'"> |
| 376 |
<xsl:text>vertical-align: </xsl:text> |
| 377 |
<xsl:value-of select="."/> |
| 378 |
<xsl:text>; </xsl:text> |
| 379 |
</xsl:when> |
| 380 |
|
| 381 |
<xsl:when test="local-name() = 'border'"> |
| 382 |
<xsl:text>border: </xsl:text> |
| 383 |
<xsl:value-of select="."/> |
| 384 |
<xsl:text>; </xsl:text> |
| 385 |
</xsl:when> |
| 386 |
|
| 387 |
<xsl:when test="local-name() = 'cellspacing'"> |
| 388 |
<xsl:text>border-spacing: </xsl:text> |
| 389 |
<xsl:value-of select="."/> |
| 390 |
<xsl:text>px</xsl:text> |
| 391 |
<xsl:text>; </xsl:text> |
| 392 |
</xsl:when> |
| 393 |
|
| 394 |
<xsl:when test="local-name() = 'cellpadding'"> |
| 395 |
<xsl:text>padding: </xsl:text> |
| 396 |
<xsl:value-of select="."/> |
| 397 |
<xsl:text>px</xsl:text> |
| 398 |
<xsl:text>; </xsl:text> |
| 399 |
</xsl:when> |
| 400 |
</xsl:choose> |
| 401 |
</xsl:for-each> |
| 402 |
</xsl:variable> |
| 403 |
|
| 404 |
<!-- merge existing styles with these new styles --> |
| 405 |
<xsl:variable name="style"> |
| 406 |
<xsl:value-of select="concat($style.from.atts, @style)"/> |
| 407 |
</xsl:variable> |
| 408 |
|
| 409 |
<!-- HTML5: reserved for element name conversion if needed --> |
| 410 |
<xsl:variable name="element.name"> |
| 411 |
<xsl:value-of select="local-name(.)"/> |
| 412 |
</xsl:variable> |
| 413 |
|
| 414 |
<xsl:element name="{$element.name}"> |
| 415 |
<xsl:if test="string-length($style) != 0"> |
| 416 |
<xsl:attribute name="style"> |
| 417 |
<xsl:value-of select="$style"/> |
| 418 |
</xsl:attribute> |
| 419 |
</xsl:if> |
| 420 |
<!-- skip converted atts, and also skip disallowed summary attribute --> |
| 421 |
<xsl:for-each select="@*"> |
| 422 |
<xsl:choose> |
| 423 |
<xsl:when test="local-name(.) = 'width' and $element != 'img'"/> |
| 424 |
<xsl:when test="local-name(.) = 'height' and $element != 'img'"/> |
| 425 |
<xsl:when test="local-name(.) = 'summary'"/> |
| 426 |
<xsl:when test="local-name(.) = 'border'"/> |
| 427 |
<xsl:when test="local-name(.) = 'cellspacing'"/> |
| 428 |
<xsl:when test="local-name(.) = 'cellpadding'"/> |
| 429 |
<xsl:when test="local-name(.) = 'style'"/> |
| 430 |
<xsl:when test="local-name(.) = 'align'"/> |
| 431 |
<xsl:when test="local-name(.) = 'valign'"/> |
| 432 |
<xsl:otherwise> |
| 433 |
<xsl:copy-of select="."/> |
| 434 |
</xsl:otherwise> |
| 435 |
</xsl:choose> |
| 436 |
</xsl:for-each> |
| 437 |
<xsl:apply-templates mode="convert.to.style"/> |
| 438 |
</xsl:element> |
| 439 |
</xsl:template> |
| 440 |
|
| 441 |
<!-- HTML5: convert some attributes to CSS style attribute --> |
| 442 |
<xsl:template match="d:entry|d:entrytbl"> |
| 443 |
<xsl:param name="col"> |
| 444 |
<xsl:choose> |
| 445 |
<xsl:when test="@revisionflag"> |
| 446 |
<xsl:number from="d:row"/> |
| 447 |
</xsl:when> |
| 448 |
<xsl:otherwise>1</xsl:otherwise> |
| 449 |
</xsl:choose> |
| 450 |
</xsl:param> |
| 451 |
|
| 452 |
<xsl:param name="spans"/> |
| 453 |
|
| 454 |
|
| 455 |
<!-- Process with stock template --> |
| 456 |
<xsl:variable name="cell"> |
| 457 |
<xsl:call-template name="entry"> |
| 458 |
<xsl:with-param name="col" select="$col"/> |
| 459 |
<xsl:with-param name="spans" select="$spans"/> |
| 460 |
</xsl:call-template> |
| 461 |
</xsl:variable> |
| 462 |
|
| 463 |
<xsl:variable name="cell.nodes" select="exsl:node-set($cell)"/> |
| 464 |
|
| 465 |
<xsl:apply-templates select="$cell.nodes" mode="convert.to.style"/> |
| 466 |
|
| 467 |
</xsl:template> |
| 468 |
|
| 469 |
<xsl:template match="d:mediaobject|d:inlinemediaobject"> |
| 470 |
<xsl:call-template name="convert.styles"/> |
| 471 |
</xsl:template> |
| 472 |
|
| 473 |
<xsl:template match="d:qandaset"> |
| 474 |
<xsl:call-template name="convert.styles"/> |
| 475 |
</xsl:template> |
| 476 |
|
| 477 |
<xsl:template match="d:calloutlist|d:revhistory|d:footnote|d:figure|d:co"> |
| 478 |
<xsl:call-template name="convert.styles"/> |
| 479 |
</xsl:template> |
| 480 |
|
| 481 |
<xsl:template match="d:revhistory" mode="titlepage.mode"> |
| 482 |
<xsl:call-template name="convert.styles"/> |
| 483 |
</xsl:template> |
| 484 |
|
| 485 |
<xsl:template match="d:variablelist"> |
| 486 |
<xsl:call-template name="convert.styles"/> |
| 487 |
</xsl:template> |
| 488 |
|
| 489 |
<xsl:template match="d:orderedlist[@inheritnum = 'inherit']"> |
| 490 |
<xsl:call-template name="convert.styles"/> |
| 491 |
</xsl:template> |
| 492 |
|
| 493 |
<xsl:template match="d:simplelist"> |
| 494 |
<xsl:call-template name="convert.styles"/> |
| 495 |
</xsl:template> |
| 496 |
|
| 497 |
<xsl:template match="d:blockquote"> |
| 498 |
<xsl:call-template name="convert.styles"/> |
| 499 |
</xsl:template> |
| 500 |
|
| 501 |
<xsl:template match="d:note|d:important|d:warning|d:caution|d:tip"> |
| 502 |
<xsl:call-template name="convert.styles"/> |
| 503 |
</xsl:template> |
| 504 |
|
| 505 |
<xsl:template match="d:funcprototype" mode="ansi-tabular"> |
| 506 |
<xsl:call-template name="convert.styles"/> |
| 507 |
</xsl:template> |
| 508 |
|
| 509 |
<xsl:template match="d:funcprototype" mode="kr-tabular"> |
| 510 |
<xsl:call-template name="convert.styles"/> |
| 511 |
</xsl:template> |
| 512 |
|
| 513 |
<xsl:template name="convert.styles"> |
| 514 |
<xsl:param name="content"> |
| 515 |
<xsl:apply-imports/> |
| 516 |
</xsl:param> |
| 517 |
<xsl:variable name="nodes" select="exsl:node-set($content)"/> |
| 518 |
|
| 519 |
<xsl:apply-templates mode="convert.to.style" select="$nodes"/> |
| 520 |
</xsl:template> |
| 521 |
|
| 522 |
<!-- HTML5: link rel="home" is not permitted --> |
| 523 |
<!-- Add support for attributes on <html> element --> |
| 524 |
<xsl:template match="*" mode="process.root"> |
| 525 |
<xsl:variable name="doc" select="self::*"/> |
| 526 |
|
| 527 |
<xsl:call-template name="user.preroot"/> |
| 528 |
<xsl:call-template name="root.messages"/> |
| 529 |
|
| 530 |
<html> |
| 531 |
<xsl:call-template name="root.attributes"/> |
| 532 |
<head> |
| 533 |
<xsl:call-template name="system.head.content"> |
| 534 |
<xsl:with-param name="node" select="$doc"/> |
| 535 |
</xsl:call-template> |
| 536 |
<xsl:call-template name="head.content"> |
| 537 |
<xsl:with-param name="node" select="$doc"/> |
| 538 |
</xsl:call-template> |
| 539 |
<xsl:call-template name="user.head.content"> |
| 540 |
<xsl:with-param name="node" select="$doc"/> |
| 541 |
</xsl:call-template> |
| 542 |
</head> |
| 543 |
<body> |
| 544 |
<xsl:call-template name="body.attributes"/> |
| 545 |
<xsl:call-template name="user.header.content"> |
| 546 |
<xsl:with-param name="node" select="$doc"/> |
| 547 |
</xsl:call-template> |
| 548 |
<xsl:apply-templates select="."/> |
| 549 |
<xsl:call-template name="user.footer.content"> |
| 550 |
<xsl:with-param name="node" select="$doc"/> |
| 551 |
</xsl:call-template> |
| 552 |
</body> |
| 553 |
</html> |
| 554 |
<xsl:value-of select="$html.append"/> |
| 555 |
|
| 556 |
<!-- Generate any css files only once, not once per chunk --> |
| 557 |
<xsl:call-template name="generate.css.files"/> |
| 558 |
</xsl:template> |
| 559 |
|
| 560 |
<xsl:template name="root.attributes"> |
| 561 |
</xsl:template> |
| 562 |
|
| 563 |
<!-- HTML5: uses <ul> instead of <dl> for TOC --> |
| 564 |
<xsl:template match="d:question" mode="qandatoc.mode"> |
| 565 |
<xsl:variable name="firstch"> |
| 566 |
<!-- Use a titleabbrev or title if available --> |
| 567 |
<xsl:choose> |
| 568 |
<xsl:when test="../d:blockinfo/d:titleabbrev"> |
| 569 |
<xsl:apply-templates select="../d:blockinfo/d:titleabbrev[1]/node()"/> |
| 570 |
</xsl:when> |
| 571 |
<xsl:when test="../d:blockinfo/d:title"> |
| 572 |
<xsl:apply-templates select="../d:blockinfo/d:title[1]/node()"/> |
| 573 |
</xsl:when> |
| 574 |
<xsl:when test="../d:info/d:titleabbrev"> |
| 575 |
<xsl:apply-templates select="../d:info/d:titleabbrev[1]/node()"/> |
| 576 |
</xsl:when> |
| 577 |
<xsl:when test="../d:titleabbrev"> |
| 578 |
<xsl:apply-templates select="../d:titleabbrev[1]/node()"/> |
| 579 |
</xsl:when> |
| 580 |
<xsl:when test="../d:info/d:title"> |
| 581 |
<xsl:apply-templates select="../d:info/d:title[1]/node()"/> |
| 582 |
</xsl:when> |
| 583 |
<xsl:when test="../d:title"> |
| 584 |
<xsl:apply-templates select="../d:title[1]/node()"/> |
| 585 |
</xsl:when> |
| 586 |
<xsl:otherwise> |
| 587 |
<xsl:apply-templates select="(*[local-name(.)!='label'])[1]/node()"/> |
| 588 |
</xsl:otherwise> |
| 589 |
</xsl:choose> |
| 590 |
</xsl:variable> |
| 591 |
<xsl:variable name="deflabel"> |
| 592 |
<xsl:choose> |
| 593 |
<xsl:when test="ancestor-or-self::*[@defaultlabel]"> |
| 594 |
<xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()] |
| 595 |
/@defaultlabel"/> |
| 596 |
</xsl:when> |
| 597 |
<xsl:otherwise> |
| 598 |
<xsl:value-of select="$qanda.defaultlabel"/> |
| 599 |
</xsl:otherwise> |
| 600 |
</xsl:choose> |
| 601 |
</xsl:variable> |
| 602 |
|
| 603 |
<li> |
| 604 |
<a> |
| 605 |
<xsl:attribute name="href"> |
| 606 |
<xsl:call-template name="href.target"> |
| 607 |
<xsl:with-param name="object" select=".."/> |
| 608 |
</xsl:call-template> |
| 609 |
</xsl:attribute> |
| 610 |
<xsl:apply-templates select="." mode="label.markup"/> |
| 611 |
<xsl:if test="contains($deflabel,'number') and not(d:label)"> |
| 612 |
<xsl:apply-templates select="." mode="intralabel.punctuation"/> |
| 613 |
</xsl:if> |
| 614 |
<xsl:text> </xsl:text> |
| 615 |
<xsl:value-of select="$firstch"/> |
| 616 |
</a> |
| 617 |
<!-- * include nested qandaset/qandaentry in TOC if user wants it --> |
| 618 |
|
| 619 |
<xsl:if test="not($qanda.nested.in.toc = 0)"> |
| 620 |
<xsl:apply-templates select="following-sibling::d:answer" mode="qandatoc.mode"/> |
| 621 |
</xsl:if> |
| 622 |
</li> |
| 623 |
</xsl:template> |
| 624 |
|
| 625 |
<xsl:template match="d:answer" mode="qandatoc.mode"> |
| 626 |
<xsl:if test="descendant::d:question"> |
| 627 |
<xsl:call-template name="process.qanda.toc"/> |
| 628 |
</xsl:if> |
| 629 |
</xsl:template> |
| 630 |
|
| 631 |
<!-- html5 uses <ul> instead of <dl> for toc --> |
| 632 |
<xsl:template name="process.qanda.toc"> |
| 633 |
<ul> |
| 634 |
<xsl:apply-templates select="d:qandadiv" mode="qandatoc.mode"/> |
| 635 |
<xsl:apply-templates select="d:qandaset|d:qandaentry" mode="qandatoc.mode"/> |
| 636 |
</ul> |
| 637 |
</xsl:template> |
| 638 |
|
| 639 |
<xsl:template match="d:qandadiv" mode="qandatoc.mode"> |
| 640 |
<!-- |
| 641 |
<dt><xsl:apply-templates select="d:title" mode="qandatoc.mode"/></dt> |
| 642 |
<dd><xsl:call-template name="process.qanda.toc"/></dd> |
| 643 |
--> |
| 644 |
<li> |
| 645 |
<xsl:apply-templates select="d:title" mode="qandatoc.mode"/> |
| 646 |
<xsl:call-template name="process.qanda.toc"/> |
| 647 |
</li> |
| 648 |
</xsl:template> |
| 649 |
|
| 650 |
<!-- output html5 video and source elements --> |
| 651 |
<xsl:template match="d:videoobject"> |
| 652 |
<video> |
| 653 |
<xsl:call-template name="common.html.attributes"/> |
| 654 |
<xsl:call-template name="video.poster"/> |
| 655 |
<!-- copy videodata attributes from first videodata child only --> |
| 656 |
<xsl:apply-templates select="d:videodata[1]/@*" mode="video.attribute"/> |
| 657 |
<xsl:apply-templates select="d:videodata[1]/d:multimediaparam" mode="video.attribute"/> |
| 658 |
|
| 659 |
<!-- generate <source> element for each videodata element --> |
| 660 |
<xsl:apply-templates select="d:videodata"/> |
| 661 |
|
| 662 |
<!-- add any fallback content --> |
| 663 |
<xsl:call-template name="video.fallback"/> |
| 664 |
|
| 665 |
</video> |
| 666 |
</xsl:template> |
| 667 |
|
| 668 |
<!-- output html5 audio and source elements --> |
| 669 |
<xsl:template match="d:audioobject"> |
| 670 |
<audio> |
| 671 |
<xsl:call-template name="common.html.attributes"/> |
| 672 |
|
| 673 |
<!-- copy audiodata attributes from first audiodata child only --> |
| 674 |
<xsl:apply-templates select="d:audiodata[1]/@*" mode="audio.attribute"/> |
| 675 |
<xsl:apply-templates select="d:audiodata[1]/d:multimediaparam" mode="audio.attribute"/> |
| 676 |
|
| 677 |
<!-- generate <source> element for each videodata element --> |
| 678 |
<xsl:apply-templates select="d:audiodata"/> |
| 679 |
|
| 680 |
<!-- add any fallback content --> |
| 681 |
<xsl:call-template name="audio.fallback"/> |
| 682 |
|
| 683 |
</audio> |
| 684 |
</xsl:template> |
| 685 |
|
| 686 |
<xsl:template match="d:videodata"> |
| 687 |
|
| 688 |
<xsl:variable name="filename"> |
| 689 |
<xsl:call-template name="mediaobject.filename"> |
| 690 |
<!-- Call it with the videodata as the object --> |
| 691 |
<xsl:with-param name="object" select="."/> |
| 692 |
</xsl:call-template> |
| 693 |
</xsl:variable> |
| 694 |
|
| 695 |
<source> |
| 696 |
<xsl:call-template name="common.html.attributes"/> |
| 697 |
|
| 698 |
<xsl:attribute name="src"> |
| 699 |
<xsl:value-of select="$filename"/> |
| 700 |
</xsl:attribute> |
| 701 |
|
| 702 |
<xsl:apply-templates select="@format" mode="source.attribute"/> |
| 703 |
|
| 704 |
<xsl:apply-templates select="d:multimediaparam" mode="source.attribute"/> |
| 705 |
|
| 706 |
</source> |
| 707 |
</xsl:template> |
| 708 |
|
| 709 |
<xsl:template match="d:audiodata"> |
| 710 |
|
| 711 |
<xsl:variable name="filename"> |
| 712 |
<xsl:call-template name="mediaobject.filename"> |
| 713 |
<!-- Call it with the videodata as the object --> |
| 714 |
<xsl:with-param name="object" select="."/> |
| 715 |
</xsl:call-template> |
| 716 |
</xsl:variable> |
| 717 |
|
| 718 |
<source> |
| 719 |
<xsl:call-template name="common.html.attributes"/> |
| 720 |
|
| 721 |
<xsl:attribute name="src"> |
| 722 |
<xsl:value-of select="$filename"/> |
| 723 |
</xsl:attribute> |
| 724 |
|
| 725 |
<xsl:apply-templates select="@format" mode="source.attribute"/> |
| 726 |
|
| 727 |
<xsl:apply-templates select="d:multimediaparam" mode="source.attribute"/> |
| 728 |
|
| 729 |
</source> |
| 730 |
</xsl:template> |
| 731 |
|
| 732 |
<!-- attributes handled in modes, so default is off --> |
| 733 |
<xsl:template match="@*" mode="source.attribute"/> |
| 734 |
<xsl:template match="@*" mode="video.attribute"/> |
| 735 |
<xsl:template match="@*" mode="audio.attribute"/> |
| 736 |
|
| 737 |
<xsl:template match="@format" mode="source.attribute"> |
| 738 |
<xsl:attribute name="type"> |
| 739 |
<xsl:value-of select="normalize-space(.)"/> |
| 740 |
</xsl:attribute> |
| 741 |
</xsl:template> |
| 742 |
|
| 743 |
<!-- use only an imageobject with @role = 'poster' --> |
| 744 |
<xsl:template name="video.poster"> |
| 745 |
<!-- context is videoobject --> |
| 746 |
<xsl:variable name="imageobject" |
| 747 |
select="../../d:imageobject[@role = 'poster'][1] | |
| 748 |
../d:imageobject[@role = 'poster'][1]"/> |
| 749 |
<xsl:if test="$imageobject"> |
| 750 |
<xsl:attribute name="poster"> |
| 751 |
<xsl:value-of select="$imageobject/d:imagedata/@fileref"/> |
| 752 |
</xsl:attribute> |
| 753 |
</xsl:if> |
| 754 |
</xsl:template> |
| 755 |
|
| 756 |
<xsl:template match="d:videodata/@fileref" mode="source.attribute"> |
| 757 |
<!-- process in normal mode --> |
| 758 |
<xsl:apply-templates select="."/> |
| 759 |
</xsl:template> |
| 760 |
|
| 761 |
<xsl:template match="d:videodata/@fileref" mode="video.attribute"/> |
| 762 |
|
| 763 |
<xsl:template match="d:audiodata/@fileref" mode="source.attribute"> |
| 764 |
<!-- process in normal mode --> |
| 765 |
<xsl:apply-templates select="."/> |
| 766 |
</xsl:template> |
| 767 |
|
| 768 |
<xsl:template match="d:audiodata/@fileref" mode="audio.attribute"/> |
| 769 |
|
| 770 |
<xsl:template match="d:videodata/@contentwidth | d:videodata/@width" |
| 771 |
mode="video.attribute"> |
| 772 |
<xsl:attribute name="width"> |
| 773 |
<xsl:value-of select="."/> |
| 774 |
</xsl:attribute> |
| 775 |
</xsl:template> |
| 776 |
|
| 777 |
<xsl:template match="d:videodata/@contentdepth | d:videodata/@depth" |
| 778 |
mode="video.attribute"> |
| 779 |
<xsl:attribute name="height"> |
| 780 |
<xsl:value-of select="."/> |
| 781 |
</xsl:attribute> |
| 782 |
</xsl:template> |
| 783 |
|
| 784 |
<xsl:template match="d:multimediaparam" mode="source.attribute"/> |
| 785 |
<xsl:template match="d:multimediaparam" mode="video.attribute"/> |
| 786 |
|
| 787 |
<xsl:template match="d:multimediaparam[@name = 'autoplay' or |
| 788 |
@name = 'controls' or |
| 789 |
@name = 'height' or |
| 790 |
@name = 'loop' or |
| 791 |
@name = 'muted' or |
| 792 |
@name = 'preload' or |
| 793 |
@name = 'width']" |
| 794 |
mode="video.attribute"> |
| 795 |
<xsl:call-template name="process.multimediaparam"> |
| 796 |
<xsl:with-param name="object" select=".."/> |
| 797 |
<xsl:with-param name="param.name" select="@name"/> |
| 798 |
<xsl:with-param name="param.value" select="@value"/> |
| 799 |
</xsl:call-template> |
| 800 |
</xsl:template> |
| 801 |
|
| 802 |
<xsl:template match="d:multimediaparam[@name = 'autoplay' or |
| 803 |
@name = 'controls' or |
| 804 |
@name = 'loop' or |
| 805 |
@name = 'muted' or |
| 806 |
@name = 'preload']" |
| 807 |
mode="audio.attribute"> |
| 808 |
<xsl:call-template name="process.multimediaparam"> |
| 809 |
<xsl:with-param name="object" select=".."/> |
| 810 |
<xsl:with-param name="param.name" select="@name"/> |
| 811 |
<xsl:with-param name="param.value" select="@value"/> |
| 812 |
</xsl:call-template> |
| 813 |
</xsl:template> |
| 814 |
|
| 815 |
<xsl:template match="d:multimediaparam[not(@name = 'autoplay' or |
| 816 |
@name = 'controls' or |
| 817 |
@name = 'height' or |
| 818 |
@name = 'loop' or |
| 819 |
@name = 'muted' or |
| 820 |
@name = 'preload' or |
| 821 |
@name = 'width')]" |
| 822 |
mode="source.attribute"> |
| 823 |
<xsl:call-template name="process.multimediaparam"> |
| 824 |
<xsl:with-param name="object" select=".."/> |
| 825 |
<xsl:with-param name="param.name" select="@name"/> |
| 826 |
<xsl:with-param name="param.value" select="@value"/> |
| 827 |
</xsl:call-template> |
| 828 |
</xsl:template> |
| 829 |
|
| 830 |
|
| 831 |
<!-- Determines the best value of a media attribute from the |
| 832 |
attributes and multimediaparam elements --> |
| 833 |
<xsl:template name="process.multimediaparam"> |
| 834 |
<xsl:param name="object" select="NOTANELEMENT"/> |
| 835 |
<xsl:param name="param.name"/> |
| 836 |
<xsl:param name="param.value"/> |
| 837 |
|
| 838 |
<xsl:choose> |
| 839 |
<xsl:when test="$object/*/@*[local-name(.) = $param.name]"> |
| 840 |
<!-- explicit attribute with that name takes precedence --> |
| 841 |
<xsl:attribute name="{$param.name}"> |
| 842 |
<xsl:value-of select="$object/*/@*[local-name(.) = $param.name]"/> |
| 843 |
</xsl:attribute> |
| 844 |
</xsl:when> |
| 845 |
<xsl:otherwise> |
| 846 |
<xsl:attribute name="{$param.name}"> |
| 847 |
<xsl:value-of select="$param.value"/> |
| 848 |
</xsl:attribute> |
| 849 |
</xsl:otherwise> |
| 850 |
</xsl:choose> |
| 851 |
</xsl:template> |
| 852 |
|
| 853 |
<xsl:template name="video.fallback"> |
| 854 |
<xsl:param name="videoobject" select="."/> |
| 855 |
<xsl:variable name="textobject" select="$videoobject/../d:textobject"/> |
| 856 |
|
| 857 |
<xsl:choose> |
| 858 |
<xsl:when test="$textobject"> |
| 859 |
<xsl:apply-templates select="$textobject" mode="fallback"/> |
| 860 |
</xsl:when> |
| 861 |
<xsl:otherwise> |
| 862 |
<xsl:call-template name="video.fallback.text"/> |
| 863 |
</xsl:otherwise> |
| 864 |
</xsl:choose> |
| 865 |
</xsl:template> |
| 866 |
|
| 867 |
<xsl:template name="video.fallback.text"> |
| 868 |
<xsl:call-template name="gentext"> |
| 869 |
<xsl:with-param name="key" select="'video-unsupported'"/> |
| 870 |
</xsl:call-template> |
| 871 |
</xsl:template> |
| 872 |
|
| 873 |
<xsl:template name="audio.fallback"> |
| 874 |
<xsl:param name="audiodata" select="."/> |
| 875 |
<xsl:variable name="textobject" select="$audiodata/../../d:textobject"/> |
| 876 |
|
| 877 |
<xsl:choose> |
| 878 |
<xsl:when test="$textobject"> |
| 879 |
<xsl:apply-templates select="$textobject" mode="fallback"/> |
| 880 |
</xsl:when> |
| 881 |
<xsl:otherwise> |
| 882 |
<xsl:call-template name="audio.fallback.text"/> |
| 883 |
</xsl:otherwise> |
| 884 |
</xsl:choose> |
| 885 |
|
| 886 |
</xsl:template> |
| 887 |
|
| 888 |
<xsl:template name="audio.fallback.text"> |
| 889 |
<xsl:call-template name="gentext"> |
| 890 |
<xsl:with-param name="key" select="'audio-unsupported'"/> |
| 891 |
</xsl:call-template> |
| 892 |
</xsl:template> |
| 893 |
|
| 894 |
<xsl:template match="d:textobject" mode="fallback"> |
| 895 |
<div> |
| 896 |
<xsl:apply-templates select="." mode="class.attribute"/> |
| 897 |
<xsl:apply-templates/> |
| 898 |
</div> |
| 899 |
</xsl:template> |
| 900 |
|
| 901 |
<!-- HTML5: no body attributes --> |
| 902 |
<xsl:template name="body.attributes"/> |
| 903 |
|
| 904 |
</xsl:stylesheet> |