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