html5-element-mods.xsl 27 KB

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