Advertisement
Guest User

xhtml2fo.xsl

a guest
Mar 2nd, 2013
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 62.00 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.  
  4. Copyright Antenna House, Inc. (http://www.antennahouse.com) 2001, 2002.
  5.  
  6. Since this stylesheet is originally developed by Antenna House to be used with XSL Formatter, it may not be compatible with another XSL-FO processors.
  7.  
  8. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, provided that the above copyright notice(s) and this permission notice appear in all copies of the Software and that both the above copyright notice(s) and this permission notice appear in supporting documentation.
  9.  
  10. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  11.  
  12. -
  13. - modifed by N. Afshartous
  14. - removed html: namespace prefix in templates so that the stylesheet would
  15. - work with DOM output of JTidy Java API.
  16. -->
  17.  
  18. <xsl:stylesheet version="1.0"
  19. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  20. xmlns:fo="http://www.w3.org/1999/XSL/Format"
  21. xmlns:html="http://www.w3.org/1999/xhtml">
  22.  
  23. <xsl:output method="xml"
  24. version="1.0"
  25. encoding="UTF-8"
  26. indent="no"/>
  27.  
  28. <!--======================================================================
  29. Parameters
  30. =======================================================================-->
  31.  
  32. <!-- page size -->
  33. <xsl:param name="page-width">auto</xsl:param>
  34. <xsl:param name="page-height">auto</xsl:param>
  35. <xsl:param name="page-margin-top">0in</xsl:param>
  36. <xsl:param name="page-margin-bottom">0in</xsl:param>
  37. <xsl:param name="page-margin-left">0in</xsl:param>
  38. <xsl:param name="page-margin-right">0in</xsl:param>
  39.  
  40. <!-- page header and footer -->
  41. <xsl:param name="page-header-margin">0in</xsl:param>
  42. <xsl:param name="page-footer-margin">0in</xsl:param>
  43. <xsl:param name="title-print-in-header">false</xsl:param>
  44. <xsl:param name="page-number-print-in-footer">false</xsl:param>
  45.  
  46. <!-- multi column -->
  47. <xsl:param name="column-count">1</xsl:param>
  48. <xsl:param name="column-gap">12pt</xsl:param>
  49.  
  50. <!-- writing-mode: lr-tb | rl-tb | tb-rl -->
  51. <xsl:param name="writing-mode">lr-tb</xsl:param>
  52.  
  53. <!-- text-align: justify | start -->
  54. <xsl:param name="text-align">start</xsl:param>
  55.  
  56. <!-- hyphenate: true | false -->
  57. <xsl:param name="hyphenate">false</xsl:param>
  58.  
  59.  
  60. <!--======================================================================
  61. Attribute Sets
  62. =======================================================================-->
  63.  
  64. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  65. Root
  66. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  67.  
  68. <xsl:attribute-set name="root">
  69. <xsl:attribute name="writing-mode"><xsl:value-of select="$writing-mode"/></xsl:attribute>
  70. <xsl:attribute name="hyphenate"><xsl:value-of select="$hyphenate"/></xsl:attribute>
  71. <xsl:attribute name="text-align"><xsl:value-of select="$text-align"/></xsl:attribute>
  72. <!-- specified on fo:root to change the properties' initial values -->
  73. </xsl:attribute-set>
  74.  
  75. <xsl:attribute-set name="page">
  76. <xsl:attribute name="page-width"><xsl:value-of select="$page-width"/></xsl:attribute>
  77. <xsl:attribute name="page-height"><xsl:value-of select="$page-height"/></xsl:attribute>
  78. <!-- specified on fo:simple-page-master -->
  79. </xsl:attribute-set>
  80.  
  81. <xsl:attribute-set name="body">
  82. <!-- specified on fo:flow's only child fo:block -->
  83. </xsl:attribute-set>
  84.  
  85. <xsl:attribute-set name="page-header">
  86. <!-- specified on (page-header)fo:static-content's only child fo:block -->
  87. <xsl:attribute name="font-size">small</xsl:attribute>
  88. <xsl:attribute name="text-align">center</xsl:attribute>
  89. </xsl:attribute-set>
  90.  
  91. <xsl:attribute-set name="page-footer">
  92. <!-- specified on (page-footer)fo:static-content's only child fo:block -->
  93. <xsl:attribute name="font-size">small</xsl:attribute>
  94. <xsl:attribute name="text-align">center</xsl:attribute>
  95. </xsl:attribute-set>
  96.  
  97. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  98. Block-level
  99. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  100.  
  101. <xsl:attribute-set name="h1">
  102. <xsl:attribute name="font-size">2em</xsl:attribute>
  103. <xsl:attribute name="font-weight">bold</xsl:attribute>
  104. <xsl:attribute name="space-before">0.67em</xsl:attribute>
  105. <xsl:attribute name="space-after">0.67em</xsl:attribute>
  106. <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
  107. <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
  108. </xsl:attribute-set>
  109.  
  110. <xsl:attribute-set name="h2">
  111. <xsl:attribute name="font-size">1.5em</xsl:attribute>
  112. <xsl:attribute name="font-weight">bold</xsl:attribute>
  113. <xsl:attribute name="space-before">0.83em</xsl:attribute>
  114. <xsl:attribute name="space-after">0.83em</xsl:attribute>
  115. <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
  116. <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
  117. </xsl:attribute-set>
  118.  
  119. <xsl:attribute-set name="h3">
  120. <xsl:attribute name="font-size">1.17em</xsl:attribute>
  121. <xsl:attribute name="font-weight">bold</xsl:attribute>
  122. <xsl:attribute name="space-before">1em</xsl:attribute>
  123. <xsl:attribute name="space-after">1em</xsl:attribute>
  124. <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
  125. <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
  126. </xsl:attribute-set>
  127.  
  128. <xsl:attribute-set name="h4">
  129. <xsl:attribute name="font-size">1em</xsl:attribute>
  130. <xsl:attribute name="font-weight">bold</xsl:attribute>
  131. <xsl:attribute name="space-before">1.17em</xsl:attribute>
  132. <xsl:attribute name="space-after">1.17em</xsl:attribute>
  133. <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
  134. <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
  135. </xsl:attribute-set>
  136.  
  137. <xsl:attribute-set name="h5">
  138. <xsl:attribute name="font-size">0.83em</xsl:attribute>
  139. <xsl:attribute name="font-weight">bold</xsl:attribute>
  140. <xsl:attribute name="space-before">1.33em</xsl:attribute>
  141. <xsl:attribute name="space-after">1.33em</xsl:attribute>
  142. <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
  143. <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
  144. </xsl:attribute-set>
  145.  
  146. <xsl:attribute-set name="h6">
  147. <xsl:attribute name="font-size">0.67em</xsl:attribute>
  148. <xsl:attribute name="font-weight">bold</xsl:attribute>
  149. <xsl:attribute name="space-before">1.67em</xsl:attribute>
  150. <xsl:attribute name="space-after">1.67em</xsl:attribute>
  151. <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
  152. <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
  153. </xsl:attribute-set>
  154.  
  155. <xsl:attribute-set name="p">
  156. <xsl:attribute name="space-before">1em</xsl:attribute>
  157. <xsl:attribute name="space-after">1em</xsl:attribute>
  158. <!-- e.g.,
  159. <xsl:attribute name="text-indent">1em</xsl:attribute>
  160. -->
  161. </xsl:attribute-set>
  162.  
  163. <xsl:attribute-set name="p-initial" use-attribute-sets="p">
  164. <!-- initial paragraph, preceded by h1..6 or div -->
  165. <!-- e.g.,
  166. <xsl:attribute name="text-indent">0em</xsl:attribute>
  167. -->
  168. </xsl:attribute-set>
  169.  
  170. <xsl:attribute-set name="p-initial-first" use-attribute-sets="p-initial">
  171. <!-- initial paragraph, first child of div, body or td -->
  172. </xsl:attribute-set>
  173.  
  174. <xsl:attribute-set name="blockquote">
  175. <xsl:attribute name="start-indent">inherited-property-value(start-indent) + 24pt</xsl:attribute>
  176. <xsl:attribute name="end-indent">inherited-property-value(end-indent) + 24pt</xsl:attribute>
  177. <xsl:attribute name="space-before">1em</xsl:attribute>
  178. <xsl:attribute name="space-after">1em</xsl:attribute>
  179. </xsl:attribute-set>
  180.  
  181. <xsl:attribute-set name="pre">
  182. <xsl:attribute name="font-size">0.83em</xsl:attribute>
  183. <xsl:attribute name="font-family">monospace</xsl:attribute>
  184. <xsl:attribute name="white-space">pre</xsl:attribute>
  185. <xsl:attribute name="space-before">1em</xsl:attribute>
  186. <xsl:attribute name="space-after">1em</xsl:attribute>
  187. </xsl:attribute-set>
  188.  
  189. <xsl:attribute-set name="address">
  190. <xsl:attribute name="font-style">italic</xsl:attribute>
  191. </xsl:attribute-set>
  192.  
  193. <xsl:attribute-set name="hr">
  194. <xsl:attribute name="border">1px inset</xsl:attribute>
  195. <xsl:attribute name="space-before">0.67em</xsl:attribute>
  196. <xsl:attribute name="space-after">0.67em</xsl:attribute>
  197. </xsl:attribute-set>
  198.  
  199. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  200. List
  201. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  202.  
  203. <xsl:attribute-set name="ul">
  204. <xsl:attribute name="space-before">1em</xsl:attribute>
  205. <xsl:attribute name="space-after">1em</xsl:attribute>
  206. </xsl:attribute-set>
  207.  
  208. <xsl:attribute-set name="ul-nested">
  209. <xsl:attribute name="space-before">0pt</xsl:attribute>
  210. <xsl:attribute name="space-after">0pt</xsl:attribute>
  211. </xsl:attribute-set>
  212.  
  213. <xsl:attribute-set name="ol">
  214. <xsl:attribute name="space-before">1em</xsl:attribute>
  215. <xsl:attribute name="space-after">1em</xsl:attribute>
  216. </xsl:attribute-set>
  217.  
  218. <xsl:attribute-set name="ol-nested">
  219. <xsl:attribute name="space-before">0pt</xsl:attribute>
  220. <xsl:attribute name="space-after">0pt</xsl:attribute>
  221. </xsl:attribute-set>
  222.  
  223. <xsl:attribute-set name="ul-li">
  224. <!-- for (unordered)fo:list-item -->
  225. <xsl:attribute name="relative-align">baseline</xsl:attribute>
  226. </xsl:attribute-set>
  227.  
  228. <xsl:attribute-set name="ol-li">
  229. <!-- for (ordered)fo:list-item -->
  230. <xsl:attribute name="relative-align">baseline</xsl:attribute>
  231. </xsl:attribute-set>
  232.  
  233. <xsl:attribute-set name="dl">
  234. <xsl:attribute name="space-before">1em</xsl:attribute>
  235. <xsl:attribute name="space-after">1em</xsl:attribute>
  236. </xsl:attribute-set>
  237.  
  238. <xsl:attribute-set name="dt">
  239. <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
  240. <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
  241. </xsl:attribute-set>
  242.  
  243. <xsl:attribute-set name="dd">
  244. <xsl:attribute name="start-indent">inherited-property-value(start-indent) + 24pt</xsl:attribute>
  245. </xsl:attribute-set>
  246.  
  247. <!-- list-item-label format for each nesting level -->
  248.  
  249. <xsl:param name="ul-label-1">&#x2022;</xsl:param>
  250. <xsl:attribute-set name="ul-label-1">
  251. <xsl:attribute name="font">1em serif</xsl:attribute>
  252. </xsl:attribute-set>
  253.  
  254. <xsl:param name="ul-label-2">o</xsl:param>
  255. <xsl:attribute-set name="ul-label-2">
  256. <xsl:attribute name="font">0.67em monospace</xsl:attribute>
  257. <xsl:attribute name="baseline-shift">0.25em</xsl:attribute>
  258. </xsl:attribute-set>
  259.  
  260. <xsl:param name="ul-label-3">-</xsl:param>
  261. <xsl:attribute-set name="ul-label-3">
  262. <xsl:attribute name="font">bold 0.9em sans-serif</xsl:attribute>
  263. <xsl:attribute name="baseline-shift">0.05em</xsl:attribute>
  264. </xsl:attribute-set>
  265.  
  266. <xsl:param name="ol-label-1">1.</xsl:param>
  267. <xsl:attribute-set name="ol-label-1"/>
  268.  
  269. <xsl:param name="ol-label-2">a.</xsl:param>
  270. <xsl:attribute-set name="ol-label-2"/>
  271.  
  272. <xsl:param name="ol-label-3">i.</xsl:param>
  273. <xsl:attribute-set name="ol-label-3"/>
  274.  
  275. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  276. Table
  277. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  278.  
  279. <xsl:attribute-set name="inside-table">
  280. <!-- prevent unwanted inheritance -->
  281. <xsl:attribute name="start-indent">0pt</xsl:attribute>
  282. <xsl:attribute name="end-indent">0pt</xsl:attribute>
  283. <xsl:attribute name="text-indent">0pt</xsl:attribute>
  284. <xsl:attribute name="last-line-end-indent">0pt</xsl:attribute>
  285. <xsl:attribute name="text-align">start</xsl:attribute>
  286. <xsl:attribute name="text-align-last">relative</xsl:attribute>
  287. </xsl:attribute-set>
  288.  
  289. <xsl:attribute-set name="table-and-caption" >
  290. <!-- horizontal alignment of table itself
  291. <xsl:attribute name="text-align">center</xsl:attribute>
  292. -->
  293. <!-- vertical alignment in table-cell -->
  294. <xsl:attribute name="display-align">center</xsl:attribute>
  295. </xsl:attribute-set>
  296.  
  297. <xsl:attribute-set name="table">
  298. <xsl:attribute name="border-collapse">separate</xsl:attribute>
  299. <xsl:attribute name="border-spacing">2px</xsl:attribute>
  300. <xsl:attribute name="border">1px</xsl:attribute>
  301. <!--
  302. <xsl:attribute name="border-style">outset</xsl:attribute>
  303. -->
  304. </xsl:attribute-set>
  305.  
  306. <xsl:attribute-set name="table-caption" use-attribute-sets="inside-table">
  307. <xsl:attribute name="text-align">center</xsl:attribute>
  308. </xsl:attribute-set>
  309.  
  310. <xsl:attribute-set name="table-column">
  311. </xsl:attribute-set>
  312.  
  313. <xsl:attribute-set name="thead" use-attribute-sets="inside-table">
  314. </xsl:attribute-set>
  315.  
  316. <xsl:attribute-set name="tfoot" use-attribute-sets="inside-table">
  317. </xsl:attribute-set>
  318.  
  319. <xsl:attribute-set name="tbody" use-attribute-sets="inside-table">
  320. </xsl:attribute-set>
  321.  
  322. <xsl:attribute-set name="tr">
  323. </xsl:attribute-set>
  324.  
  325. <xsl:attribute-set name="th">
  326. <xsl:attribute name="font-weight">bolder</xsl:attribute>
  327. <xsl:attribute name="text-align">center</xsl:attribute>
  328. <xsl:attribute name="border">1px</xsl:attribute>
  329. <!--
  330. <xsl:attribute name="border-style">inset</xsl:attribute>
  331. -->
  332. <xsl:attribute name="padding">1px</xsl:attribute>
  333. </xsl:attribute-set>
  334.  
  335. <xsl:attribute-set name="td">
  336. <xsl:attribute name="border">1px</xsl:attribute>
  337. <!--
  338. <xsl:attribute name="border-style">inset</xsl:attribute>
  339. -->
  340. <xsl:attribute name="padding">1px</xsl:attribute>
  341. </xsl:attribute-set>
  342.  
  343. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  344. Inline-level
  345. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  346.  
  347. <xsl:attribute-set name="b">
  348. <xsl:attribute name="font-weight">bolder</xsl:attribute>
  349. </xsl:attribute-set>
  350. <xsl:attribute-set name="strong">
  351. <xsl:attribute name="font-weight">bolder</xsl:attribute>
  352. </xsl:attribute-set>
  353.  
  354. <xsl:attribute-set name="strong-em">
  355. <xsl:attribute name="font-weight">bolder</xsl:attribute>
  356. <xsl:attribute name="font-style">italic</xsl:attribute>
  357. </xsl:attribute-set>
  358.  
  359. <xsl:attribute-set name="i">
  360. <xsl:attribute name="font-style">italic</xsl:attribute>
  361. </xsl:attribute-set>
  362. <xsl:attribute-set name="cite">
  363. <xsl:attribute name="font-style">italic</xsl:attribute>
  364. </xsl:attribute-set>
  365. <xsl:attribute-set name="em">
  366. <xsl:attribute name="font-style">italic</xsl:attribute>
  367. </xsl:attribute-set>
  368. <xsl:attribute-set name="var">
  369. <xsl:attribute name="font-style">italic</xsl:attribute>
  370. </xsl:attribute-set>
  371. <xsl:attribute-set name="dfn">
  372. <xsl:attribute name="font-style">italic</xsl:attribute>
  373. </xsl:attribute-set>
  374.  
  375. <xsl:attribute-set name="tt">
  376. <xsl:attribute name="font-family">monospace</xsl:attribute>
  377. </xsl:attribute-set>
  378. <xsl:attribute-set name="code">
  379. <xsl:attribute name="font-family">monospace</xsl:attribute>
  380. </xsl:attribute-set>
  381. <xsl:attribute-set name="kbd">
  382. <xsl:attribute name="font-family">monospace</xsl:attribute>
  383. </xsl:attribute-set>
  384. <xsl:attribute-set name="samp">
  385. <xsl:attribute name="font-family">monospace</xsl:attribute>
  386. </xsl:attribute-set>
  387.  
  388. <xsl:attribute-set name="big">
  389. <xsl:attribute name="font-size">larger</xsl:attribute>
  390. </xsl:attribute-set>
  391. <xsl:attribute-set name="small">
  392. <xsl:attribute name="font-size">smaller</xsl:attribute>
  393. </xsl:attribute-set>
  394.  
  395. <xsl:attribute-set name="sub">
  396. <xsl:attribute name="baseline-shift">sub</xsl:attribute>
  397. <xsl:attribute name="font-size">smaller</xsl:attribute>
  398. </xsl:attribute-set>
  399. <xsl:attribute-set name="sup">
  400. <xsl:attribute name="baseline-shift">super</xsl:attribute>
  401. <xsl:attribute name="font-size">smaller</xsl:attribute>
  402. </xsl:attribute-set>
  403.  
  404. <xsl:attribute-set name="s">
  405. <xsl:attribute name="text-decoration">line-through</xsl:attribute>
  406. </xsl:attribute-set>
  407. <xsl:attribute-set name="strike">
  408. <xsl:attribute name="text-decoration">line-through</xsl:attribute>
  409. </xsl:attribute-set>
  410. <xsl:attribute-set name="del">
  411. <xsl:attribute name="text-decoration">line-through</xsl:attribute>
  412. </xsl:attribute-set>
  413.  
  414. <xsl:attribute-set name="u">
  415. <xsl:attribute name="text-decoration">underline</xsl:attribute>
  416. </xsl:attribute-set>
  417. <xsl:attribute-set name="ins">
  418. <xsl:attribute name="text-decoration">underline</xsl:attribute>
  419. </xsl:attribute-set>
  420.  
  421. <xsl:attribute-set name="abbr">
  422. <!-- e.g.,
  423. <xsl:attribute name="font-variant">small-caps</xsl:attribute>
  424. <xsl:attribute name="letter-spacing">0.1em</xsl:attribute>
  425. -->
  426. </xsl:attribute-set>
  427.  
  428. <xsl:attribute-set name="acronym">
  429. <!-- e.g.,
  430. <xsl:attribute name="font-variant">small-caps</xsl:attribute>
  431. <xsl:attribute name="letter-spacing">0.1em</xsl:attribute>
  432. -->
  433. </xsl:attribute-set>
  434.  
  435. <xsl:attribute-set name="q"/>
  436. <xsl:attribute-set name="q-nested"/>
  437.  
  438. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  439. Image
  440. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  441.  
  442. <xsl:attribute-set name="img">
  443. </xsl:attribute-set>
  444.  
  445. <xsl:attribute-set name="img-link">
  446. <xsl:attribute name="border">2px solid</xsl:attribute>
  447. </xsl:attribute-set>
  448.  
  449. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  450. Link
  451. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  452.  
  453. <xsl:attribute-set name="a-link">
  454. <xsl:attribute name="text-decoration">underline</xsl:attribute>
  455. <xsl:attribute name="color">blue</xsl:attribute>
  456. </xsl:attribute-set>
  457.  
  458.  
  459. <!--======================================================================
  460. Templates
  461. =======================================================================-->
  462.  
  463. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  464. Root
  465. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  466.  
  467. <xsl:template match="html">
  468. <fo:root xsl:use-attribute-sets="root">
  469. <xsl:call-template name="process-common-attributes"/>
  470. <xsl:call-template name="make-layout-master-set"/>
  471. <xsl:apply-templates/>
  472. </fo:root>
  473. </xsl:template>
  474.  
  475. <xsl:template name="make-layout-master-set">
  476. <fo:layout-master-set>
  477. <fo:simple-page-master master-name="all-pages"
  478. xsl:use-attribute-sets="page">
  479. <fo:region-body margin-top="{$page-margin-top}"
  480. margin-right="{$page-margin-right}"
  481. margin-bottom="{$page-margin-bottom}"
  482. margin-left="{$page-margin-left}"
  483. column-count="{$column-count}"
  484. column-gap="{$column-gap}"/>
  485. <xsl:choose>
  486. <xsl:when test="$writing-mode = 'tb-rl'">
  487. <fo:region-before extent="{$page-margin-right}"
  488. precedence="true"/>
  489. <fo:region-after extent="{$page-margin-left}"
  490. precedence="true"/>
  491. <fo:region-start region-name="page-header"
  492. extent="{$page-margin-top}"
  493. writing-mode="lr-tb"
  494. display-align="before"/>
  495. <fo:region-end region-name="page-footer"
  496. extent="{$page-margin-bottom}"
  497. writing-mode="lr-tb"
  498. display-align="after"/>
  499. </xsl:when>
  500. <xsl:when test="$writing-mode = 'rl-tb'">
  501. <fo:region-before region-name="page-header"
  502. extent="{$page-margin-top}"
  503. display-align="before"/>
  504. <fo:region-after region-name="page-footer"
  505. extent="{$page-margin-bottom}"
  506. display-align="after"/>
  507. <fo:region-start extent="{$page-margin-right}"/>
  508. <fo:region-end extent="{$page-margin-left}"/>
  509. </xsl:when>
  510. <xsl:otherwise><!-- $writing-mode = 'lr-tb' -->
  511. <fo:region-before region-name="page-header"
  512. extent="{$page-margin-top}"
  513. display-align="before"/>
  514. <fo:region-after region-name="page-footer"
  515. extent="{$page-margin-bottom}"
  516. display-align="after"/>
  517. <fo:region-start extent="{$page-margin-left}"/>
  518. <fo:region-end extent="{$page-margin-bottom}"/>
  519. </xsl:otherwise>
  520. </xsl:choose>
  521. </fo:simple-page-master>
  522. </fo:layout-master-set>
  523. </xsl:template>
  524.  
  525. <xsl:template match="head | script"/>
  526.  
  527. <xsl:template match="body">
  528. <fo:page-sequence master-reference="all-pages">
  529. <fo:title>
  530. <xsl:value-of select="/html/head/title"/>
  531. </fo:title>
  532. <fo:static-content flow-name="page-header">
  533. <fo:block space-before.conditionality="retain"
  534. space-before="{$page-header-margin}"
  535. xsl:use-attribute-sets="page-header">
  536. <xsl:if test="$title-print-in-header = 'true'">
  537. <xsl:value-of select="/html/head/title"/>
  538. </xsl:if>
  539. </fo:block>
  540. </fo:static-content>
  541. <fo:static-content flow-name="page-footer">
  542. <fo:block space-after.conditionality="retain"
  543. space-after="{$page-footer-margin}"
  544. xsl:use-attribute-sets="page-footer">
  545. <xsl:if test="$page-number-print-in-footer = 'true'">
  546. <xsl:text>- </xsl:text>
  547. <fo:page-number/>
  548. <xsl:text> -</xsl:text>
  549. </xsl:if>
  550. </fo:block>
  551. </fo:static-content>
  552. <fo:flow flow-name="xsl-region-body">
  553. <fo:block keep-together.within-page="always" xsl:use-attribute-sets="body">
  554. <xsl:call-template name="process-common-attributes"/>
  555. <xsl:apply-templates/>
  556. </fo:block>
  557. </fo:flow>
  558. </fo:page-sequence>
  559. </xsl:template>
  560.  
  561. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  562. process common attributes and children
  563. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  564.  
  565. <xsl:template name="process-common-attributes-and-children">
  566. <xsl:call-template name="process-common-attributes"/>
  567. <xsl:apply-templates/>
  568. </xsl:template>
  569.  
  570. <xsl:template name="process-common-attributes">
  571. <xsl:attribute name="role">
  572. <xsl:value-of select="concat('', local-name())"/>
  573. </xsl:attribute>
  574.  
  575. <xsl:choose>
  576. <xsl:when test="@xml:lang">
  577. <xsl:attribute name="xml:lang">
  578. <xsl:value-of select="@xml:lang"/>
  579. </xsl:attribute>
  580. </xsl:when>
  581. <xsl:when test="@lang">
  582. <xsl:attribute name="xml:lang">
  583. <xsl:value-of select="@lang"/>
  584. </xsl:attribute>
  585. </xsl:when>
  586. </xsl:choose>
  587.  
  588. <xsl:choose>
  589. <xsl:when test="@id">
  590. <xsl:attribute name="id">
  591. <xsl:value-of select="@id"/>
  592. </xsl:attribute>
  593. </xsl:when>
  594. <xsl:when test="self::a/@name">
  595. <xsl:attribute name="id">
  596. <xsl:value-of select="@name"/>
  597. </xsl:attribute>
  598. </xsl:when>
  599. </xsl:choose>
  600.  
  601. <xsl:if test="@align">
  602. <xsl:choose>
  603. <xsl:when test="self::caption">
  604. </xsl:when>
  605. <xsl:when test="self::img or self::object">
  606. <xsl:if test="@align = 'bottom' or @align = 'middle' or @align = 'top'">
  607. <xsl:attribute name="vertical-align">
  608. <xsl:value-of select="@align"/>
  609. </xsl:attribute>
  610. </xsl:if>
  611. </xsl:when>
  612. <xsl:otherwise>
  613. <xsl:call-template name="process-cell-align">
  614. <xsl:with-param name="align" select="@align"/>
  615. </xsl:call-template>
  616. </xsl:otherwise>
  617. </xsl:choose>
  618. </xsl:if>
  619. <xsl:if test="@valign">
  620. <xsl:call-template name="process-cell-valign">
  621. <xsl:with-param name="valign" select="@valign"/>
  622. </xsl:call-template>
  623. </xsl:if>
  624.  
  625. <xsl:if test="@style">
  626. <xsl:call-template name="process-style">
  627. <xsl:with-param name="style" select="@style"/>
  628. </xsl:call-template>
  629. </xsl:if>
  630.  
  631. <xsl:if test="@STYLE">
  632. <xsl:call-template name="process-style">
  633. <xsl:with-param name="style" select="@style"/>
  634. </xsl:call-template>
  635. </xsl:if>
  636.  
  637. </xsl:template>
  638.  
  639. <xsl:template name="process-style">
  640. <xsl:param name="style"/>
  641. <!-- e.g., style="text-align: center; color: red"
  642. converted to text-align="center" color="red" -->
  643. <xsl:variable name="name"
  644. select="normalize-space(substring-before($style, ':'))"/>
  645. <xsl:if test="$name">
  646. <xsl:variable name="value-and-rest"
  647. select="normalize-space(substring-after($style, ':'))"/>
  648. <xsl:variable name="value">
  649. <xsl:choose>
  650. <xsl:when test="contains($value-and-rest, ';')">
  651. <xsl:value-of select="normalize-space(substring-before(
  652. $value-and-rest, ';'))"/>
  653. </xsl:when>
  654. <xsl:otherwise>
  655. <xsl:value-of select="$value-and-rest"/>
  656. </xsl:otherwise>
  657. </xsl:choose>
  658. </xsl:variable>
  659. <xsl:choose>
  660. <xsl:when test="$name = 'width' and (self::col or self::colgroup)">
  661. <xsl:attribute name="column-width">
  662. <xsl:value-of select="$value"/>
  663. </xsl:attribute>
  664. </xsl:when>
  665.  
  666. <xsl:when test="$name = 'clip'">
  667. <!-- No OP -->
  668. </xsl:when>
  669. <xsl:when test="$name = 'vertical-align' and (
  670. self::table or self::caption or
  671. self::thead or self::tfoot or
  672. self::tbody or self::colgroup or
  673. self::col or self::tr or
  674. self::th or self::td)">
  675. <xsl:choose>
  676. <xsl:when test="$value = 'top'">
  677. <xsl:attribute name="display-align">before</xsl:attribute>
  678. </xsl:when>
  679. <xsl:when test="$value = 'bottom'">
  680. <xsl:attribute name="display-align">after</xsl:attribute>
  681. </xsl:when>
  682. <xsl:when test="$value = 'middle'">
  683. <xsl:attribute name="display-align">center</xsl:attribute>
  684. </xsl:when>
  685. <xsl:otherwise>
  686. <xsl:attribute name="display-align">auto</xsl:attribute>
  687. <xsl:attribute name="relative-align">baseline</xsl:attribute>
  688. </xsl:otherwise>
  689. </xsl:choose>
  690. </xsl:when>
  691. <xsl:otherwise>
  692. <xsl:attribute name="{$name}">
  693. <xsl:value-of select="$value"/>
  694. </xsl:attribute>
  695. </xsl:otherwise>
  696. </xsl:choose>
  697. </xsl:if>
  698. <xsl:variable name="rest"
  699. select="normalize-space(substring-after($style, ';'))"/>
  700. <xsl:if test="$rest">
  701. <xsl:call-template name="process-style">
  702. <xsl:with-param name="style" select="$rest"/>
  703. </xsl:call-template>
  704. </xsl:if>
  705. </xsl:template>
  706.  
  707.  
  708. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  709. Block-level
  710. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  711.  
  712. <xsl:template match="h1">
  713. <fo:block xsl:use-attribute-sets="h1">
  714. <xsl:call-template name="process-common-attributes-and-children"/>
  715. </fo:block>
  716. </xsl:template>
  717.  
  718. <xsl:template match="h2">
  719. <fo:block xsl:use-attribute-sets="h2">
  720. <xsl:call-template name="process-common-attributes-and-children"/>
  721. </fo:block>
  722. </xsl:template>
  723.  
  724. <xsl:template match="h3">
  725. <fo:block xsl:use-attribute-sets="h3">
  726. <xsl:call-template name="process-common-attributes-and-children"/>
  727. </fo:block>
  728. </xsl:template>
  729.  
  730. <xsl:template match="h4">
  731. <fo:block xsl:use-attribute-sets="h4">
  732. <xsl:call-template name="process-common-attributes-and-children"/>
  733. </fo:block>
  734. </xsl:template>
  735.  
  736. <xsl:template match="h5">
  737. <fo:block xsl:use-attribute-sets="h5">
  738. <xsl:call-template name="process-common-attributes-and-children"/>
  739. </fo:block>
  740. </xsl:template>
  741.  
  742. <xsl:template match="h6">
  743. <fo:block xsl:use-attribute-sets="h6">
  744. <xsl:call-template name="process-common-attributes-and-children"/>
  745. </fo:block>
  746. </xsl:template>
  747.  
  748. <xsl:template match="p">
  749. <fo:block xsl:use-attribute-sets="p">
  750. <xsl:call-template name="process-common-attributes-and-children"/>
  751. </fo:block>
  752. </xsl:template>
  753.  
  754. <!-- initial paragraph, preceded by h1..6 or div -->
  755. <xsl:template match="p[preceding-sibling::*[1][
  756. self::h1 or self::h2 or self::h3 or
  757. self::h4 or self::h5 or self::h6 or
  758. self::div]]">
  759. <fo:block xsl:use-attribute-sets="p-initial">
  760. <xsl:call-template name="process-common-attributes-and-children"/>
  761. </fo:block>
  762. </xsl:template>
  763.  
  764. <!-- initial paragraph, first child of div, body or td -->
  765. <xsl:template match="p[not(preceding-sibling::*) and (
  766. parent::div or
  767. parent::body or
  768. parent::td)]">
  769. <fo:block xsl:use-attribute-sets="p-initial-first">
  770. <xsl:call-template name="process-common-attributes-and-children"/>
  771. </fo:block>
  772. </xsl:template>
  773.  
  774. <xsl:template match="blockquote">
  775. <fo:block xsl:use-attribute-sets="blockquote">
  776. <xsl:call-template name="process-common-attributes-and-children"/>
  777. </fo:block>
  778. </xsl:template>
  779.  
  780. <xsl:template match="pre">
  781. <fo:block xsl:use-attribute-sets="pre">
  782. <xsl:call-template name="process-pre"/>
  783. </fo:block>
  784. </xsl:template>
  785.  
  786. <xsl:template name="process-pre">
  787. <xsl:call-template name="process-common-attributes"/>
  788. <!-- remove leading CR/LF/CRLF char -->
  789. <xsl:variable name="crlf"><xsl:text>&#xD;&#xA;</xsl:text></xsl:variable>
  790. <xsl:variable name="lf"><xsl:text>&#xA;</xsl:text></xsl:variable>
  791. <xsl:variable name="cr"><xsl:text>&#xD;</xsl:text></xsl:variable>
  792. <xsl:for-each select="node()">
  793. <xsl:choose>
  794. <xsl:when test="position() = 1 and self::text()">
  795. <xsl:choose>
  796. <xsl:when test="starts-with(., $lf)">
  797. <xsl:value-of select="substring(., 2)"/>
  798. </xsl:when>
  799. <xsl:when test="starts-with(., $crlf)">
  800. <xsl:value-of select="substring(., 3)"/>
  801. </xsl:when>
  802. <xsl:when test="starts-with(., $cr)">
  803. <xsl:value-of select="substring(., 2)"/>
  804. </xsl:when>
  805. <xsl:otherwise>
  806. <xsl:apply-templates select="."/>
  807. </xsl:otherwise>
  808. </xsl:choose>
  809. </xsl:when>
  810. <xsl:otherwise>
  811. <xsl:apply-templates select="."/>
  812. </xsl:otherwise>
  813. </xsl:choose>
  814. </xsl:for-each>
  815. </xsl:template>
  816.  
  817. <xsl:template match="address">
  818. <fo:block xsl:use-attribute-sets="address">
  819. <xsl:call-template name="process-common-attributes-and-children"/>
  820. </fo:block>
  821. </xsl:template>
  822.  
  823. <xsl:template match="hr">
  824. <fo:block xsl:use-attribute-sets="hr">
  825. <xsl:call-template name="process-common-attributes"/>
  826. </fo:block>
  827. </xsl:template>
  828.  
  829. <xsl:template match="div">
  830. <!-- need fo:block-container? or normal fo:block -->
  831. <xsl:variable name="need-block-container">
  832. <xsl:call-template name="need-block-container"/>
  833. </xsl:variable>
  834. <xsl:choose>
  835. <xsl:when test="$need-block-container = 'true'">
  836. <fo:block-container keep-together.within-page="always" overflow="scroll">
  837. <xsl:if test="@dir">
  838. <xsl:attribute name="writing-mode">
  839. <xsl:choose>
  840. <xsl:when test="@dir = 'rtl'">rl-tb</xsl:when>
  841. <xsl:otherwise>lr-tb</xsl:otherwise>
  842. </xsl:choose>
  843. </xsl:attribute>
  844. </xsl:if>
  845. <xsl:call-template name="process-common-attributes"/>
  846. <fo:block start-indent="0pt" end-indent="0pt">
  847. <xsl:apply-templates/>
  848. </fo:block>
  849. </fo:block-container>
  850. </xsl:when>
  851. <xsl:otherwise>
  852. <!-- normal block -->
  853. <fo:block keep-together.within-page="always" overflow="scroll">
  854. <xsl:call-template name="process-common-attributes"/>
  855. <xsl:apply-templates/>
  856. </fo:block>
  857. </xsl:otherwise>
  858. </xsl:choose>
  859. </xsl:template>
  860.  
  861. <xsl:template name="need-block-container">
  862. <xsl:choose>
  863. <xsl:when test="@dir">true</xsl:when>
  864. <xsl:when test="@style">
  865. <xsl:variable name="s"
  866. select="concat(';', translate(normalize-space(@style),
  867. ' ', ''))"/>
  868. <xsl:choose>
  869. <xsl:when test="contains($s, ';width:') or
  870. contains($s, ';height:') or
  871. contains($s, ';position:absolute') or
  872. contains($s, ';position:fixed') or
  873. contains($s, ';writing-mode:')">true</xsl:when>
  874. <xsl:otherwise>false</xsl:otherwise>
  875. </xsl:choose>
  876. </xsl:when>
  877. <xsl:otherwise>false</xsl:otherwise>
  878. </xsl:choose>
  879. </xsl:template>
  880.  
  881. <xsl:template match="center">
  882. <fo:block text-align="center">
  883. <xsl:call-template name="process-common-attributes-and-children"/>
  884. </fo:block>
  885. </xsl:template>
  886.  
  887. <xsl:template match="fieldset | form | dir | menu">
  888. <fo:block space-before="1em" space-after="1em">
  889. <xsl:call-template name="process-common-attributes-and-children"/>
  890. </fo:block>
  891. </xsl:template>
  892.  
  893. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  894. List
  895. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  896.  
  897. <xsl:template match="ul">
  898. <fo:list-block xsl:use-attribute-sets="ul">
  899. <xsl:call-template name="process-common-attributes-and-children"/>
  900. </fo:list-block>
  901. </xsl:template>
  902.  
  903. <xsl:template match="li//ul">
  904. <fo:list-block xsl:use-attribute-sets="ul-nested">
  905. <xsl:call-template name="process-common-attributes-and-children"/>
  906. </fo:list-block>
  907. </xsl:template>
  908.  
  909. <xsl:template match="ol">
  910. <fo:list-block xsl:use-attribute-sets="ol">
  911. <xsl:call-template name="process-common-attributes-and-children"/>
  912. </fo:list-block>
  913. </xsl:template>
  914.  
  915. <xsl:template match="li//ol">
  916. <fo:list-block xsl:use-attribute-sets="ol-nested">
  917. <xsl:call-template name="process-common-attributes-and-children"/>
  918. </fo:list-block>
  919. </xsl:template>
  920.  
  921. <xsl:template match="ul/li">
  922. <fo:list-item xsl:use-attribute-sets="ul-li">
  923. <xsl:call-template name="process-ul-li"/>
  924. </fo:list-item>
  925. </xsl:template>
  926.  
  927. <xsl:template name="process-ul-li">
  928. <xsl:call-template name="process-common-attributes"/>
  929. <fo:list-item-label end-indent="label-end()"
  930. text-align="end" wrap-option="no-wrap">
  931. <fo:block>
  932. <xsl:variable name="depth" select="count(ancestor::ul)" />
  933. <xsl:choose>
  934. <xsl:when test="$depth = 1">
  935. <fo:inline xsl:use-attribute-sets="ul-label-1">
  936. <xsl:value-of select="$ul-label-1"/>
  937. </fo:inline>
  938. </xsl:when>
  939. <xsl:when test="$depth = 2">
  940. <fo:inline xsl:use-attribute-sets="ul-label-2">
  941. <xsl:value-of select="$ul-label-2"/>
  942. </fo:inline>
  943. </xsl:when>
  944. <xsl:otherwise>
  945. <fo:inline xsl:use-attribute-sets="ul-label-3">
  946. <xsl:value-of select="$ul-label-3"/>
  947. </fo:inline>
  948. </xsl:otherwise>
  949. </xsl:choose>
  950. </fo:block>
  951. </fo:list-item-label>
  952. <fo:list-item-body start-indent="body-start()">
  953. <fo:block>
  954. <xsl:apply-templates/>
  955. </fo:block>
  956. </fo:list-item-body>
  957. </xsl:template>
  958.  
  959. <xsl:template match="ol/li">
  960. <fo:list-item xsl:use-attribute-sets="ol-li">
  961. <xsl:call-template name="process-ol-li"/>
  962. </fo:list-item>
  963. </xsl:template>
  964.  
  965. <xsl:template name="process-ol-li">
  966. <xsl:call-template name="process-common-attributes"/>
  967. <fo:list-item-label end-indent="label-end()"
  968. text-align="end" wrap-option="no-wrap">
  969. <fo:block>
  970. <xsl:variable name="depth" select="count(ancestor::ol)" />
  971. <xsl:choose>
  972. <xsl:when test="$depth = 1">
  973. <fo:inline xsl:use-attribute-sets="ol-label-1">
  974. <xsl:number format="{$ol-label-1}"/>
  975. </fo:inline>
  976. </xsl:when>
  977. <xsl:when test="$depth = 2">
  978. <fo:inline xsl:use-attribute-sets="ol-label-2">
  979. <xsl:number format="{$ol-label-2}"/>
  980. </fo:inline>
  981. </xsl:when>
  982. <xsl:otherwise>
  983. <fo:inline xsl:use-attribute-sets="ol-label-3">
  984. <xsl:number format="{$ol-label-3}"/>
  985. </fo:inline>
  986. </xsl:otherwise>
  987. </xsl:choose>
  988. </fo:block>
  989. </fo:list-item-label>
  990. <fo:list-item-body start-indent="body-start()">
  991. <fo:block>
  992. <xsl:apply-templates/>
  993. </fo:block>
  994. </fo:list-item-body>
  995. </xsl:template>
  996.  
  997. <xsl:template match="dl">
  998. <fo:block xsl:use-attribute-sets="dl">
  999. <xsl:call-template name="process-common-attributes-and-children"/>
  1000. </fo:block>
  1001. </xsl:template>
  1002.  
  1003. <xsl:template match="dt">
  1004. <fo:block xsl:use-attribute-sets="dt">
  1005. <xsl:call-template name="process-common-attributes-and-children"/>
  1006. </fo:block>
  1007. </xsl:template>
  1008.  
  1009. <xsl:template match="dd">
  1010. <fo:block xsl:use-attribute-sets="dd">
  1011. <xsl:call-template name="process-common-attributes-and-children"/>
  1012. </fo:block>
  1013. </xsl:template>
  1014.  
  1015. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1016. Table
  1017. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  1018.  
  1019. <xsl:template match="table">
  1020. <fo:table-and-caption xsl:use-attribute-sets="table-and-caption">
  1021. <xsl:call-template name="make-table-caption"/>
  1022. <fo:table xsl:use-attribute-sets="table">
  1023. <xsl:call-template name="process-table"/>
  1024. </fo:table>
  1025. </fo:table-and-caption>
  1026. </xsl:template>
  1027.  
  1028. <xsl:template name="make-table-caption">
  1029. <xsl:if test="caption/@align">
  1030. <xsl:attribute name="caption-side">
  1031. <xsl:value-of select="caption/@align"/>
  1032. </xsl:attribute>
  1033. </xsl:if>
  1034. <xsl:apply-templates select="caption"/>
  1035. </xsl:template>
  1036.  
  1037. <xsl:template name="process-table">
  1038. <xsl:if test="@width">
  1039. <xsl:attribute name="inline-progression-dimension">
  1040. <xsl:choose>
  1041. <xsl:when test="contains(@width, '%')">
  1042. <xsl:value-of select="@width"/>
  1043. </xsl:when>
  1044. <xsl:otherwise>
  1045. <xsl:value-of select="@width"/>px</xsl:otherwise>
  1046. </xsl:choose>
  1047. </xsl:attribute>
  1048. </xsl:if>
  1049. <xsl:if test="@border or @frame">
  1050. <xsl:choose>
  1051. <xsl:when test="@border &gt; 0">
  1052. <xsl:attribute name="border">
  1053. <xsl:value-of select="@border"/>px</xsl:attribute>
  1054. </xsl:when>
  1055. </xsl:choose>
  1056. <xsl:choose>
  1057. <xsl:when test="@border = '0' or @frame = 'void'">
  1058. <xsl:attribute name="border-style">hidden</xsl:attribute>
  1059. </xsl:when>
  1060. <xsl:when test="@frame = 'above'">
  1061. <xsl:attribute name="border-style">outset hidden hidden hidden</xsl:attribute>
  1062. </xsl:when>
  1063. <xsl:when test="@frame = 'below'">
  1064. <xsl:attribute name="border-style">hidden hidden outset hidden</xsl:attribute>
  1065. </xsl:when>
  1066. <xsl:when test="@frame = 'hsides'">
  1067. <xsl:attribute name="border-style">outset hidden</xsl:attribute>
  1068. </xsl:when>
  1069. <xsl:when test="@frame = 'vsides'">
  1070. <xsl:attribute name="border-style">hidden outset</xsl:attribute>
  1071. </xsl:when>
  1072. <xsl:when test="@frame = 'lhs'">
  1073. <xsl:attribute name="border-style">hidden hidden hidden outset</xsl:attribute>
  1074. </xsl:when>
  1075. <xsl:when test="@frame = 'rhs'">
  1076. <xsl:attribute name="border-style">hidden outset hidden hidden</xsl:attribute>
  1077. </xsl:when>
  1078. <xsl:otherwise>
  1079. <xsl:attribute name="border-style">outset</xsl:attribute>
  1080. </xsl:otherwise>
  1081. </xsl:choose>
  1082. </xsl:if>
  1083. <xsl:if test="@cellspacing">
  1084. <xsl:attribute name="border-spacing">
  1085. <xsl:value-of select="@cellspacing"/>px</xsl:attribute>
  1086. <xsl:attribute name="border-collapse">separate</xsl:attribute>
  1087. </xsl:if>
  1088. <xsl:if test="@rules and (@rules = 'groups' or
  1089. @rules = 'rows' or
  1090. @rules = 'cols' or
  1091. @rules = 'all' and (not(@border or @frame) or
  1092. @border = '0' or @frame and
  1093. not(@frame = 'box' or @frame = 'border')))">
  1094. <xsl:attribute name="border-collapse">collapse</xsl:attribute>
  1095. <xsl:if test="not(@border or @frame)">
  1096. <xsl:attribute name="border-style">hidden</xsl:attribute>
  1097. </xsl:if>
  1098. </xsl:if>
  1099. <xsl:call-template name="process-common-attributes"/>
  1100. <xsl:apply-templates select="col | colgroup"/>
  1101. <xsl:apply-templates select="thead"/>
  1102. <xsl:apply-templates select="tfoot"/>
  1103. <xsl:choose>
  1104. <xsl:when test="tbody">
  1105. <xsl:apply-templates select="tbody"/>
  1106. </xsl:when>
  1107. <xsl:otherwise>
  1108. <fo:table-body xsl:use-attribute-sets="tbody">
  1109. <xsl:apply-templates select="tr"/>
  1110. </fo:table-body>
  1111. </xsl:otherwise>
  1112. </xsl:choose>
  1113. </xsl:template>
  1114.  
  1115. <xsl:template match="caption">
  1116. <fo:table-caption xsl:use-attribute-sets="table-caption">
  1117. <xsl:call-template name="process-common-attributes"/>
  1118. <fo:block>
  1119. <xsl:apply-templates/>
  1120. </fo:block>
  1121. </fo:table-caption>
  1122. </xsl:template>
  1123.  
  1124. <xsl:template match="thead">
  1125. <fo:table-header xsl:use-attribute-sets="thead">
  1126. <xsl:call-template name="process-table-rowgroup"/>
  1127. </fo:table-header>
  1128. </xsl:template>
  1129.  
  1130. <xsl:template match="tfoot">
  1131. <fo:table-footer xsl:use-attribute-sets="tfoot">
  1132. <xsl:call-template name="process-table-rowgroup"/>
  1133. </fo:table-footer>
  1134. </xsl:template>
  1135.  
  1136. <xsl:template match="tbody">
  1137. <fo:table-body xsl:use-attribute-sets="tbody">
  1138. <xsl:call-template name="process-table-rowgroup"/>
  1139. </fo:table-body>
  1140. </xsl:template>
  1141.  
  1142. <xsl:template name="process-table-rowgroup">
  1143. <xsl:if test="ancestor::table[1]/@rules = 'groups'">
  1144. <xsl:attribute name="border">1px solid</xsl:attribute>
  1145. </xsl:if>
  1146. <xsl:call-template name="process-common-attributes-and-children"/>
  1147. </xsl:template>
  1148.  
  1149. <xsl:template match="colgroup">
  1150. <fo:table-column xsl:use-attribute-sets="table-column">
  1151. <xsl:call-template name="process-table-column"/>
  1152. </fo:table-column>
  1153. </xsl:template>
  1154.  
  1155. <xsl:template match="colgroup[col]">
  1156. <xsl:apply-templates/>
  1157. </xsl:template>
  1158.  
  1159. <xsl:template match="col">
  1160. <fo:table-column xsl:use-attribute-sets="table-column">
  1161. <xsl:call-template name="process-table-column"/>
  1162. </fo:table-column>
  1163. </xsl:template>
  1164.  
  1165. <xsl:template name="process-table-column">
  1166. <xsl:if test="parent::colgroup">
  1167. <xsl:call-template name="process-col-width">
  1168. <xsl:with-param name="width" select="../@width"/>
  1169. </xsl:call-template>
  1170. <xsl:call-template name="process-cell-align">
  1171. <xsl:with-param name="align" select="../@align"/>
  1172. </xsl:call-template>
  1173. <xsl:call-template name="process-cell-valign">
  1174. <xsl:with-param name="valign" select="../@valign"/>
  1175. </xsl:call-template>
  1176. </xsl:if>
  1177. <xsl:if test="@span">
  1178. <xsl:attribute name="number-columns-repeated">
  1179. <xsl:value-of select="@span"/>
  1180. </xsl:attribute>
  1181. </xsl:if>
  1182. <xsl:call-template name="process-col-width">
  1183. <xsl:with-param name="width" select="@width"/>
  1184. <!-- it may override parent colgroup's width -->
  1185. </xsl:call-template>
  1186. <xsl:if test="ancestor::table[1]/@rules = 'cols'">
  1187. <xsl:attribute name="border">1px solid</xsl:attribute>
  1188. </xsl:if>
  1189. <xsl:call-template name="process-common-attributes"/>
  1190. <!-- this processes also align and valign -->
  1191. </xsl:template>
  1192.  
  1193. <xsl:template match="tr">
  1194. <fo:table-row xsl:use-attribute-sets="tr">
  1195. <xsl:call-template name="process-table-row"/>
  1196. </fo:table-row>
  1197. </xsl:template>
  1198.  
  1199. <xsl:template match="tr[parent::table and th and not(td)]">
  1200. <fo:table-row xsl:use-attribute-sets="tr" keep-with-next="always">
  1201. <xsl:call-template name="process-table-row"/>
  1202. </fo:table-row>
  1203. </xsl:template>
  1204.  
  1205. <xsl:template name="process-table-row">
  1206. <xsl:if test="ancestor::table[1]/@rules = 'rows'">
  1207. <xsl:attribute name="border">1px solid</xsl:attribute>
  1208. </xsl:if>
  1209. <xsl:call-template name="process-common-attributes-and-children"/>
  1210. </xsl:template>
  1211.  
  1212. <xsl:template match="th">
  1213. <fo:table-cell xsl:use-attribute-sets="th">
  1214. <xsl:call-template name="process-table-cell"/>
  1215. </fo:table-cell>
  1216. </xsl:template>
  1217.  
  1218. <xsl:template match="td">
  1219. <fo:table-cell xsl:use-attribute-sets="td">
  1220. <xsl:call-template name="process-table-cell"/>
  1221. </fo:table-cell>
  1222. </xsl:template>
  1223.  
  1224. <xsl:template name="process-table-cell">
  1225. <xsl:if test="@colspan">
  1226. <xsl:attribute name="number-columns-spanned">
  1227. <xsl:value-of select="@colspan"/>
  1228. </xsl:attribute>
  1229. </xsl:if>
  1230. <xsl:if test="@rowspan">
  1231. <xsl:attribute name="number-rows-spanned">
  1232. <xsl:value-of select="@rowspan"/>
  1233. </xsl:attribute>
  1234. </xsl:if>
  1235. <xsl:for-each select="ancestor::table[1]">
  1236. <xsl:if test="(@border or @rules) and (@rules = 'all' or
  1237. not(@rules) and not(@border = '0'))">
  1238. <xsl:attribute name="border-style">inset</xsl:attribute>
  1239. </xsl:if>
  1240. <xsl:if test="@cellpadding">
  1241. <xsl:attribute name="padding">
  1242. <xsl:choose>
  1243. <xsl:when test="contains(@cellpadding, '%')">
  1244. <xsl:value-of select="@cellpadding"/>
  1245. </xsl:when>
  1246. <xsl:otherwise>
  1247. <xsl:value-of select="@cellpadding"/>px</xsl:otherwise>
  1248. </xsl:choose>
  1249. </xsl:attribute>
  1250. </xsl:if>
  1251. </xsl:for-each>
  1252. <xsl:if test="not(@align or ../@align or
  1253. ../parent::*[self::thead or self::tfoot or
  1254. self::tbody]/@align) and
  1255. ancestor::table[1]/*[self::col or
  1256. self::colgroup]/descendant-or-self::*/@align">
  1257. <xsl:attribute name="text-align">from-table-column()</xsl:attribute>
  1258. </xsl:if>
  1259. <xsl:if test="not(@valign or ../@valign or
  1260. ../parent::*[self::thead or self::tfoot or
  1261. self::tbody]/@valign) and
  1262. ancestor::table[1]/*[self::col or
  1263. self::colgroup]/descendant-or-self::*/@valign">
  1264. <xsl:attribute name="display-align">from-table-column()</xsl:attribute>
  1265. <xsl:attribute name="relative-align">from-table-column()</xsl:attribute>
  1266. </xsl:if>
  1267. <xsl:call-template name="process-common-attributes"/>
  1268. <fo:block>
  1269. <xsl:apply-templates/>
  1270. </fo:block>
  1271. </xsl:template>
  1272.  
  1273. <xsl:template name="process-col-width">
  1274. <xsl:param name="width"/>
  1275. <xsl:if test="$width and $width != '0*'">
  1276. <xsl:attribute name="column-width">
  1277. <xsl:choose>
  1278. <xsl:when test="contains($width, '*')">
  1279. <xsl:text>proportional-column-width(</xsl:text>
  1280. <xsl:value-of select="substring-before($width, '*')"/>
  1281. <xsl:text>)</xsl:text>
  1282. </xsl:when>
  1283. <xsl:when test="contains($width, '%')">
  1284. <xsl:value-of select="$width"/>
  1285. </xsl:when>
  1286. <xsl:otherwise>
  1287. <xsl:value-of select="$width"/>px</xsl:otherwise>
  1288. </xsl:choose>
  1289. </xsl:attribute>
  1290. </xsl:if>
  1291. </xsl:template>
  1292.  
  1293. <xsl:template name="process-cell-align">
  1294. <xsl:param name="align"/>
  1295. <xsl:if test="$align">
  1296. <xsl:attribute name="text-align">
  1297. <xsl:choose>
  1298. <xsl:when test="$align = 'char'">
  1299. <xsl:choose>
  1300. <xsl:when test="$align/../@char">
  1301. <xsl:value-of select="$align/../@char"/>
  1302. </xsl:when>
  1303. <xsl:otherwise>
  1304. <xsl:value-of select="'.'"/>
  1305. <!-- todo: it should depend on xml:lang ... -->
  1306. </xsl:otherwise>
  1307. </xsl:choose>
  1308. </xsl:when>
  1309. <xsl:otherwise>
  1310. <xsl:value-of select="$align"/>
  1311. </xsl:otherwise>
  1312. </xsl:choose>
  1313. </xsl:attribute>
  1314. </xsl:if>
  1315. </xsl:template>
  1316.  
  1317. <xsl:template name="process-cell-valign">
  1318. <xsl:param name="valign"/>
  1319. <xsl:if test="$valign">
  1320. <xsl:attribute name="display-align">
  1321. <xsl:choose>
  1322. <xsl:when test="$valign = 'middle'">center</xsl:when>
  1323. <xsl:when test="$valign = 'bottom'">after</xsl:when>
  1324. <xsl:when test="$valign = 'baseline'">auto</xsl:when>
  1325. <xsl:otherwise>before</xsl:otherwise>
  1326. </xsl:choose>
  1327. </xsl:attribute>
  1328. <xsl:if test="$valign = 'baseline'">
  1329. <xsl:attribute name="relative-align">baseline</xsl:attribute>
  1330. </xsl:if>
  1331. </xsl:if>
  1332. </xsl:template>
  1333.  
  1334. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1335. Inline-level
  1336. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  1337.  
  1338. <xsl:template match="b">
  1339. <fo:inline xsl:use-attribute-sets="b">
  1340. <xsl:call-template name="process-common-attributes-and-children"/>
  1341. </fo:inline>
  1342. </xsl:template>
  1343.  
  1344. <xsl:template match="strong">
  1345. <fo:inline xsl:use-attribute-sets="strong">
  1346. <xsl:call-template name="process-common-attributes-and-children"/>
  1347. </fo:inline>
  1348. </xsl:template>
  1349.  
  1350. <xsl:template match="strong//em | em//strong">
  1351. <fo:inline xsl:use-attribute-sets="strong-em">
  1352. <xsl:call-template name="process-common-attributes-and-children"/>
  1353. </fo:inline>
  1354. </xsl:template>
  1355.  
  1356. <xsl:template match="i">
  1357. <fo:inline xsl:use-attribute-sets="i">
  1358. <xsl:call-template name="process-common-attributes-and-children"/>
  1359. </fo:inline>
  1360. </xsl:template>
  1361.  
  1362. <xsl:template match="cite">
  1363. <fo:inline xsl:use-attribute-sets="cite">
  1364. <xsl:call-template name="process-common-attributes-and-children"/>
  1365. </fo:inline>
  1366. </xsl:template>
  1367.  
  1368. <xsl:template match="em">
  1369. <fo:inline xsl:use-attribute-sets="em">
  1370. <xsl:call-template name="process-common-attributes-and-children"/>
  1371. </fo:inline>
  1372. </xsl:template>
  1373.  
  1374. <xsl:template match="var">
  1375. <fo:inline xsl:use-attribute-sets="var">
  1376. <xsl:call-template name="process-common-attributes-and-children"/>
  1377. </fo:inline>
  1378. </xsl:template>
  1379.  
  1380. <xsl:template match="dfn">
  1381. <fo:inline xsl:use-attribute-sets="dfn">
  1382. <xsl:call-template name="process-common-attributes-and-children"/>
  1383. </fo:inline>
  1384. </xsl:template>
  1385.  
  1386. <xsl:template match="tt">
  1387. <fo:inline xsl:use-attribute-sets="tt">
  1388. <xsl:call-template name="process-common-attributes-and-children"/>
  1389. </fo:inline>
  1390. </xsl:template>
  1391.  
  1392. <xsl:template match="code">
  1393. <fo:inline xsl:use-attribute-sets="code">
  1394. <xsl:call-template name="process-common-attributes-and-children"/>
  1395. </fo:inline>
  1396. </xsl:template>
  1397.  
  1398. <xsl:template match="kbd">
  1399. <fo:inline xsl:use-attribute-sets="kbd">
  1400. <xsl:call-template name="process-common-attributes-and-children"/>
  1401. </fo:inline>
  1402. </xsl:template>
  1403.  
  1404. <xsl:template match="samp">
  1405. <fo:inline xsl:use-attribute-sets="samp">
  1406. <xsl:call-template name="process-common-attributes-and-children"/>
  1407. </fo:inline>
  1408. </xsl:template>
  1409.  
  1410. <xsl:template match="big">
  1411. <fo:inline xsl:use-attribute-sets="big">
  1412. <xsl:call-template name="process-common-attributes-and-children"/>
  1413. </fo:inline>
  1414. </xsl:template>
  1415.  
  1416. <xsl:template match="small">
  1417. <fo:inline xsl:use-attribute-sets="small">
  1418. <xsl:call-template name="process-common-attributes-and-children"/>
  1419. </fo:inline>
  1420. </xsl:template>
  1421.  
  1422. <xsl:template match="sub">
  1423. <fo:inline xsl:use-attribute-sets="sub">
  1424. <xsl:call-template name="process-common-attributes-and-children"/>
  1425. </fo:inline>
  1426. </xsl:template>
  1427.  
  1428. <xsl:template match="sup">
  1429. <fo:inline xsl:use-attribute-sets="sup">
  1430. <xsl:call-template name="process-common-attributes-and-children"/>
  1431. </fo:inline>
  1432. </xsl:template>
  1433.  
  1434. <xsl:template match="s">
  1435. <fo:inline xsl:use-attribute-sets="s">
  1436. <xsl:call-template name="process-common-attributes-and-children"/>
  1437. </fo:inline>
  1438. </xsl:template>
  1439.  
  1440. <xsl:template match="strike">
  1441. <fo:inline xsl:use-attribute-sets="strike">
  1442. <xsl:call-template name="process-common-attributes-and-children"/>
  1443. </fo:inline>
  1444. </xsl:template>
  1445.  
  1446. <xsl:template match="del">
  1447. <fo:inline xsl:use-attribute-sets="del">
  1448. <xsl:call-template name="process-common-attributes-and-children"/>
  1449. </fo:inline>
  1450. </xsl:template>
  1451.  
  1452. <xsl:template match="u">
  1453. <fo:inline xsl:use-attribute-sets="u">
  1454. <xsl:call-template name="process-common-attributes-and-children"/>
  1455. </fo:inline>
  1456. </xsl:template>
  1457.  
  1458. <xsl:template match="ins">
  1459. <fo:inline xsl:use-attribute-sets="ins">
  1460. <xsl:call-template name="process-common-attributes-and-children"/>
  1461. </fo:inline>
  1462. </xsl:template>
  1463.  
  1464. <xsl:template match="abbr">
  1465. <fo:inline xsl:use-attribute-sets="abbr">
  1466. <xsl:call-template name="process-common-attributes-and-children"/>
  1467. </fo:inline>
  1468. </xsl:template>
  1469.  
  1470. <xsl:template match="acronym">
  1471. <fo:inline xsl:use-attribute-sets="acronym">
  1472. <xsl:call-template name="process-common-attributes-and-children"/>
  1473. </fo:inline>
  1474. </xsl:template>
  1475.  
  1476. <xsl:template match="span">
  1477. <fo:inline>
  1478. <xsl:call-template name="process-common-attributes-and-children"/>
  1479. </fo:inline>
  1480. </xsl:template>
  1481.  
  1482. <xsl:template match="span[@dir]">
  1483. <fo:bidi-override direction="{@dir}" unicode-bidi="embed">
  1484. <xsl:call-template name="process-common-attributes-and-children"/>
  1485. </fo:bidi-override>
  1486. </xsl:template>
  1487.  
  1488. <xsl:template match="span[@style and contains(@style, 'writing-mode')]">
  1489. <fo:inline-container alignment-baseline="central"
  1490. text-indent="0pt"
  1491. last-line-end-indent="0pt"
  1492. start-indent="0pt"
  1493. end-indent="0pt"
  1494. text-align="center"
  1495. text-align-last="center">
  1496. <xsl:call-template name="process-common-attributes"/>
  1497. <fo:block wrap-option="no-wrap" line-height="1">
  1498. <xsl:apply-templates/>
  1499. </fo:block>
  1500. </fo:inline-container>
  1501. </xsl:template>
  1502.  
  1503. <xsl:template match="bdo">
  1504. <fo:bidi-override direction="{@dir}" unicode-bidi="bidi-override">
  1505. <xsl:call-template name="process-common-attributes-and-children"/>
  1506. </fo:bidi-override>
  1507. </xsl:template>
  1508.  
  1509. <xsl:template match="br">
  1510. <fo:block>
  1511. <xsl:call-template name="process-common-attributes"/>
  1512. </fo:block>
  1513. </xsl:template>
  1514.  
  1515. <xsl:template match="q">
  1516. <fo:inline xsl:use-attribute-sets="q">
  1517. <xsl:call-template name="process-common-attributes"/>
  1518. <xsl:choose>
  1519. <xsl:when test="lang('ja')">
  1520. <xsl:text>「</xsl:text>
  1521. <xsl:apply-templates/>
  1522. <xsl:text>」</xsl:text>
  1523. </xsl:when>
  1524. <xsl:otherwise>
  1525. <!-- lang('en') -->
  1526. <xsl:text>“</xsl:text>
  1527. <xsl:apply-templates/>
  1528. <xsl:text>”</xsl:text>
  1529. <!-- todo: other languages ...-->
  1530. </xsl:otherwise>
  1531. </xsl:choose>
  1532. </fo:inline>
  1533. </xsl:template>
  1534.  
  1535. <xsl:template match="q//q">
  1536. <fo:inline xsl:use-attribute-sets="q-nested">
  1537. <xsl:call-template name="process-common-attributes"/>
  1538. <xsl:choose>
  1539. <xsl:when test="lang('ja')">
  1540. <xsl:text>『</xsl:text>
  1541. <xsl:apply-templates/>
  1542. <xsl:text>』</xsl:text>
  1543. </xsl:when>
  1544. <xsl:otherwise>
  1545. <!-- lang('en') -->
  1546. <xsl:text>‘</xsl:text>
  1547. <xsl:apply-templates/>
  1548. <xsl:text>’</xsl:text>
  1549. </xsl:otherwise>
  1550. </xsl:choose>
  1551. </fo:inline>
  1552. </xsl:template>
  1553.  
  1554. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1555. Image
  1556. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  1557.  
  1558. <xsl:template match="img">
  1559. <fo:external-graphic xsl:use-attribute-sets="img">
  1560. <xsl:call-template name="process-img"/>
  1561. </fo:external-graphic>
  1562. </xsl:template>
  1563.  
  1564. <xsl:template match="img[ancestor::a/@href]">
  1565. <fo:external-graphic xsl:use-attribute-sets="img-link">
  1566. <xsl:call-template name="process-img"/>
  1567. </fo:external-graphic>
  1568. </xsl:template>
  1569.  
  1570. <xsl:template name="process-img">
  1571. <xsl:attribute name="src">
  1572. <xsl:text>url('</xsl:text>
  1573. <xsl:value-of select="@src"/>
  1574. <xsl:text>')</xsl:text>
  1575. </xsl:attribute>
  1576. <xsl:if test="@alt">
  1577. <xsl:attribute name="role">
  1578. <xsl:value-of select="@alt"/>
  1579. </xsl:attribute>
  1580. </xsl:if>
  1581. <xsl:if test="@width">
  1582. <xsl:choose>
  1583. <xsl:when test="contains(@width, '%')">
  1584. <xsl:attribute name="width">
  1585. <xsl:value-of select="@width"/>
  1586. </xsl:attribute>
  1587. <xsl:attribute name="content-width">scale-to-fit</xsl:attribute>
  1588. </xsl:when>
  1589. <xsl:otherwise>
  1590. <xsl:attribute name="content-width">
  1591. <xsl:value-of select="@width"/>px</xsl:attribute>
  1592. </xsl:otherwise>
  1593. </xsl:choose>
  1594. </xsl:if>
  1595. <xsl:if test="@height">
  1596. <xsl:choose>
  1597. <xsl:when test="contains(@height, '%')">
  1598. <xsl:attribute name="height">
  1599. <xsl:value-of select="@height"/>
  1600. </xsl:attribute>
  1601. <xsl:attribute name="content-height">scale-to-fit</xsl:attribute>
  1602. </xsl:when>
  1603. <xsl:otherwise>
  1604. <xsl:attribute name="content-height">
  1605. <xsl:value-of select="@height"/>px</xsl:attribute>
  1606. </xsl:otherwise>
  1607. </xsl:choose>
  1608. </xsl:if>
  1609. <xsl:if test="@border">
  1610. <xsl:attribute name="border">
  1611. <xsl:value-of select="@border"/>px solid</xsl:attribute>
  1612. </xsl:if>
  1613. <xsl:call-template name="process-common-attributes"/>
  1614. </xsl:template>
  1615.  
  1616. <xsl:template match="object">
  1617. <xsl:apply-templates/>
  1618. </xsl:template>
  1619.  
  1620. <xsl:template match="param"/>
  1621. <xsl:template match="map"/>
  1622. <xsl:template match="area"/>
  1623. <xsl:template match="label"/>
  1624. <xsl:template match="input"/>
  1625. <xsl:template match="select"/>
  1626. <xsl:template match="optgroup"/>
  1627. <xsl:template match="option"/>
  1628. <xsl:template match="textarea"/>
  1629. <xsl:template match="legend"/>
  1630. <xsl:template match="button"/>
  1631.  
  1632. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1633. Link
  1634. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  1635.  
  1636. <xsl:template match="a">
  1637. <fo:inline>
  1638. <xsl:call-template name="process-common-attributes-and-children"/>
  1639. </fo:inline>
  1640. </xsl:template>
  1641.  
  1642. <xsl:template match="a[@href]">
  1643. <fo:basic-link xsl:use-attribute-sets="a-link">
  1644. <xsl:call-template name="process-a-link"/>
  1645. </fo:basic-link>
  1646. </xsl:template>
  1647.  
  1648. <xsl:template name="process-a-link">
  1649. <xsl:call-template name="process-common-attributes"/>
  1650. <xsl:choose>
  1651. <xsl:when test="starts-with(@href,'#')">
  1652. <xsl:attribute name="internal-destination">
  1653. <xsl:value-of select="substring-after(@href,'#')"/>
  1654. </xsl:attribute>
  1655. </xsl:when>
  1656. <xsl:otherwise>
  1657. <xsl:attribute name="external-destination">
  1658. <xsl:text>url('</xsl:text>
  1659. <xsl:value-of select="@href"/>
  1660. <xsl:text>')</xsl:text>
  1661. </xsl:attribute>
  1662. </xsl:otherwise>
  1663. </xsl:choose>
  1664. <xsl:if test="@title">
  1665. <xsl:attribute name="role">
  1666. <xsl:value-of select="@title"/>
  1667. </xsl:attribute>
  1668. </xsl:if>
  1669. <xsl:apply-templates/>
  1670. </xsl:template>
  1671.  
  1672. <!--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1673. Ruby
  1674. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-->
  1675.  
  1676. <xsl:template match="ruby">
  1677. <fo:inline-container alignment-baseline="central"
  1678. block-progression-dimension="1em"
  1679. text-indent="0pt"
  1680. last-line-end-indent="0pt"
  1681. start-indent="0pt"
  1682. end-indent="0pt"
  1683. text-align="center"
  1684. text-align-last="center">
  1685. <xsl:call-template name="process-common-attributes"/>
  1686. <fo:block font-size="50%"
  1687. wrap-option="no-wrap"
  1688. line-height="1"
  1689. space-before.conditionality="retain"
  1690. space-before="-1.1em"
  1691. space-after="0.1em"
  1692. role="rt">
  1693. <xsl:for-each select="rt | rtc[1]/rt">
  1694. <xsl:call-template name="process-common-attributes"/>
  1695. <xsl:apply-templates/>
  1696. </xsl:for-each>
  1697. </fo:block>
  1698. <fo:block wrap-option="no-wrap" line-height="1" role="rb">
  1699. <xsl:for-each select="rb | rbc[1]/rb">
  1700. <xsl:call-template name="process-common-attributes"/>
  1701. <xsl:apply-templates/>
  1702. </xsl:for-each>
  1703. </fo:block>
  1704. <xsl:if test="rtc[2]/rt">
  1705. <fo:block font-size="50%"
  1706. wrap-option="no-wrap"
  1707. line-height="1"
  1708. space-before="0.1em"
  1709. space-after.conditionality="retain"
  1710. space-after="-1.1em"
  1711. role="rt">
  1712. <xsl:for-each select="rt | rtc[2]/rt">
  1713. <xsl:call-template name="process-common-attributes"/>
  1714. <xsl:apply-templates/>
  1715. </xsl:for-each>
  1716. </fo:block>
  1717. </xsl:if>
  1718. </fo:inline-container>
  1719. </xsl:template>
  1720. </xsl:stylesheet>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement