You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xml2pdf.xsl 8.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <?xml version="1.0"?>
  2. <!-- XSLT stylesheet to convert the Fop documentation collected in one xml file into a fo file
  3. for use in FOP
  4. TBD: - The faq doesn't show in the content
  5. - check why margin-bottom on the page with properties is too large
  6. - check why keep-next not only doesn't work, but leads to repeating already printed lines
  7. - make lines containing only code look nicer (smaller line height)
  8. - replace bullets in ordered lists with numbers
  9. - correct the hack replacing nbsp with '-'
  10. - handle the links correctly which have been external in the html doc and are now internal
  11. -->
  12. <xsl:stylesheet
  13. xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  14. xmlns:fo="http://www.w3.org/1999/XSL/Format"
  15. >
  16. <xsl:template match ="/">
  17. <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
  18. <!-- defines page layout -->
  19. <fo:layout-master-set>
  20. <fo:simple-page-master master-name="simple"
  21. page-height="29.7cm"
  22. page-width="21cm"
  23. margin-top="1.5cm"
  24. margin-bottom="2cm"
  25. margin-left="2.5cm"
  26. margin-right="2.5cm">
  27. <fo:region-body margin-top="3cm"/>
  28. <fo:region-before extent="1.5cm"/>
  29. <fo:region-after extent="1.5cm"/>
  30. </fo:simple-page-master>
  31. </fo:layout-master-set>
  32. <fo:page-sequence master-name="simple">
  33. <fo:static-content flow-name="xsl-region-before">
  34. <fo:block text-align="end"
  35. font-size="10pt"
  36. font-family="serif"
  37. line-height="14pt" >
  38. FOP documentation - p. <fo:page-number/>
  39. </fo:block>
  40. </fo:static-content>
  41. <fo:flow flow-name="xsl-region-body">
  42. <fo:block font-size="18pt"
  43. font-family="sans-serif"
  44. line-height="24pt"
  45. space-after.optimum="15pt"
  46. background-color="blue"
  47. color="white"
  48. text-align="center">
  49. FOP - an xsl:fo renderer
  50. </fo:block>
  51. <!-- generates table of contents and puts it into a table -->
  52. <fo:block font-size="14pt"
  53. font-family="sans-serif"
  54. line-height="18pt"
  55. space-after.optimum="10pt"
  56. font-weight="bold"
  57. start-indent="15pt">
  58. Content
  59. </fo:block>
  60. <fo:table>
  61. <fo:table-column column-width="1cm"/>
  62. <fo:table-column column-width="15cm"/>
  63. <fo:table-body font-size="12pt"
  64. line-height="16pt"
  65. font-family="sans-serif">
  66. <xsl:for-each select="//s1">
  67. <fo:table-row>
  68. <fo:table-cell>
  69. <fo:block text-align="end" >
  70. <xsl:number value="position()" format="1"/>)
  71. </fo:block>
  72. </fo:table-cell>
  73. <fo:table-cell>
  74. <fo:block text-align="start" >
  75. <fo:basic-link color="blue">
  76. <xsl:attribute name="internal-destination">
  77. <xsl:value-of select="translate(.,' ),-.(','____')"/>
  78. </xsl:attribute>
  79. <xsl:value-of select="@title"/>
  80. </fo:basic-link>
  81. </fo:block>
  82. </fo:table-cell>
  83. </fo:table-row>
  84. </xsl:for-each>
  85. </fo:table-body>
  86. </fo:table>
  87. <xsl:apply-templates select="documentation"/>
  88. </fo:flow>
  89. </fo:page-sequence>
  90. </fo:root>
  91. </xsl:template>
  92. <!-- s1 -->
  93. <xsl:template match ="s1">
  94. <fo:block font-size="18pt"
  95. font-family="sans-serif"
  96. line-height="24pt"
  97. space-before.optimum="15pt"
  98. space-after.optimum="15pt"
  99. background-color="blue"
  100. color="white"
  101. text-align="center"
  102. >
  103. <xsl:attribute name="id">
  104. <xsl:value-of select="translate(.,' ),-.(','____')"/>
  105. </xsl:attribute>
  106. <xsl:value-of select="@title"/>
  107. </fo:block>
  108. <xsl:apply-templates/>
  109. </xsl:template>
  110. <!-- s2 -->
  111. <xsl:template match ="s2">
  112. <fo:block font-size="16pt"
  113. font-family="sans-serif"
  114. line-height="20pt"
  115. space-before.optimum="15pt"
  116. space-after.optimum="12pt"
  117. text-align="center"
  118. padding-top="3pt"
  119. >
  120. <xsl:value-of select="@title"/>
  121. </fo:block>
  122. <xsl:apply-templates/>
  123. </xsl:template>
  124. <!-- s3 -->
  125. <xsl:template match ="s3">
  126. <fo:block font-size="14pt"
  127. font-family="sans-serif"
  128. line-height="18pt"
  129. space-before.optimum="10pt"
  130. space-after.optimum="9pt"
  131. text-align="start"
  132. padding-top="3pt">
  133. <xsl:value-of select="@title"/>
  134. </fo:block>
  135. <xsl:apply-templates/>
  136. </xsl:template>
  137. <!-- p [not(code)] -->
  138. <xsl:template match ="p">
  139. <fo:block font-size="11pt"
  140. font-family="sans-serif"
  141. line-height="13pt"
  142. space-after.optimum="3pt"
  143. space-before.optimum="3pt"
  144. text-align="justify">
  145. <xsl:apply-templates/>
  146. </fo:block>
  147. </xsl:template>
  148. <!-- p + code
  149. <xsl:template match ="p[code]">
  150. <fo:block font-size="11pt"
  151. font-family="sans-serif"
  152. line-height="11pt"
  153. space-after.optimum="0pt"
  154. space-before.optimum="0pt"
  155. text-align="start">
  156. <xsl:apply-templates/>
  157. </fo:block>
  158. </xsl:template>
  159. -->
  160. <!-- faqs -->
  161. <xsl:template match ="faqs">
  162. <fo:block font-size="18pt"
  163. font-family="sans-serif"
  164. line-height="24pt"
  165. space-before.optimum="15pt"
  166. space-after.optimum="15pt"
  167. background-color="blue"
  168. color="white"
  169. text-align="center"
  170. >
  171. <xsl:attribute name="id">
  172. <xsl:value-of select="translate(.,' ),-.(','____')"/>
  173. </xsl:attribute>
  174. <xsl:value-of select="@title"/>
  175. </fo:block>
  176. <xsl:apply-templates/>
  177. </xsl:template>
  178. <!-- faq -->
  179. <xsl:template match ="faq">
  180. <xsl:apply-templates/>
  181. </xsl:template>
  182. <!-- q in faq -->
  183. <xsl:template match ="q">
  184. <fo:block font-size="11pt"
  185. font-family="sans-serif"
  186. line-height="13pt"
  187. space-after.optimum="3pt"
  188. space-before.optimum="3pt"
  189. text-align="justify">
  190. <xsl:apply-templates/>
  191. </fo:block>
  192. </xsl:template>
  193. <!-- a in faq -->
  194. <xsl:template match ="a">
  195. <xsl:apply-templates/>
  196. </xsl:template>
  197. <!-- jump (links) -->
  198. <xsl:template match ="*/jump">
  199. <fo:basic-link color="blue" external-destination="{@href}">
  200. <xsl:apply-templates/>
  201. </fo:basic-link>
  202. </xsl:template>
  203. <!-- code -->
  204. <xsl:template match ="*/code">
  205. <fo:inline font-size="10pt"
  206. font-family="Courier">
  207. <xsl:apply-templates/>
  208. </fo:inline>
  209. </xsl:template>
  210. <!-- ul (unordered list) -->
  211. <xsl:template match ="ul">
  212. <fo:list-block start-indent="1cm"
  213. provisional-distance-between-starts="12pt"
  214. font-family="sans-serif"
  215. font-size="11pt"
  216. line-height="11pt">
  217. <xsl:apply-templates/>
  218. </fo:list-block>
  219. </xsl:template>
  220. <!-- ol (ordered list) -->
  221. <xsl:template match ="ol">
  222. <fo:list-block start-indent="1cm"
  223. provisional-distance-between-starts="12pt"
  224. font-family="sans-serif"
  225. font-size="11pt"
  226. line-height="11pt">
  227. <xsl:apply-templates/>
  228. </fo:list-block>
  229. </xsl:template>
  230. <!-- li (list item) in unordered list -->
  231. <xsl:template match ="ul/li">
  232. <fo:list-item>
  233. <fo:list-item-label end-indent="label-end()">
  234. <fo:block><fo:inline font-family="Symbol">&#183;</fo:inline></fo:block>
  235. </fo:list-item-label>
  236. <fo:list-item-body start-indent="body-start()">
  237. <fo:block space-after.optimum="4pt"
  238. text-align="justify"
  239. padding-top="3pt">
  240. <xsl:apply-templates/>
  241. </fo:block>
  242. </fo:list-item-body>
  243. </fo:list-item>
  244. </xsl:template>
  245. <!-- li (list item) in ordered list -->
  246. <xsl:template match ="ol/li">
  247. <fo:list-item>
  248. <fo:list-item-label end-indent="label-end()">
  249. <fo:block>
  250. <xsl:number level="multiple" count="li" format="1"/>)
  251. </fo:block>
  252. </fo:list-item-label>
  253. <fo:list-item-body start-indent="body-start()">
  254. <fo:block space-after.optimum="4pt"
  255. text-align="justify"
  256. padding-top="3pt">
  257. <xsl:apply-templates/>
  258. </fo:block>
  259. </fo:list-item-body>
  260. </fo:list-item>
  261. </xsl:template>
  262. <!-- end body -->
  263. </xsl:stylesheet>