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 9.2KB

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