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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <!--
  2. Copyright 1999-2004 The Apache Software Foundation
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. -->
  13. <!-- $Id$ -->
  14. <xsl:stylesheet
  15. xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  16. xmlns:fo="http://www.w3.org/1999/XSL/Format">
  17. <xsl:template match ="root">
  18. <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
  19. <!-- defines page layout -->
  20. <fo:layout-master-set>
  21. <fo:simple-page-master master-name="simple"
  22. page-height="29.7cm"
  23. page-width="21cm"
  24. margin-top="1.5cm"
  25. margin-bottom="1.5cm"
  26. margin-left="2.5cm"
  27. margin-right="2.5cm">
  28. <fo:region-body margin-top="1.5cm"/>
  29. <fo:region-before extent="1.5cm"/>
  30. <fo:region-after extent="1.5cm"/>
  31. </fo:simple-page-master>
  32. </fo:layout-master-set>
  33. <fo:page-sequence master-reference="simple">
  34. <fo:static-content flow-name="xsl-region-before">
  35. <fo:block text-align="end"
  36. font-size="10pt"
  37. font-family="serif"
  38. line-height="14pt" >
  39. xsl:fo short reference - p. <fo:page-number/>
  40. </fo:block>
  41. </fo:static-content>
  42. <fo:flow flow-name="xsl-region-body">
  43. <fo:block font-size="18pt"
  44. font-family="sans-serif"
  45. line-height="24pt"
  46. space-after.optimum="15pt"
  47. background-color="blue"
  48. color="white"
  49. text-align="center">
  50. xsl:fo short reference
  51. </fo:block>
  52. <!-- generates table of contents and puts it into a table -->
  53. <fo:block font-size="10pt"
  54. font-family="sans-serif"
  55. line-height="10pt"
  56. space-after.optimum="3pt"
  57. font-weight="bold"
  58. start-indent="15pt">
  59. Content
  60. </fo:block>
  61. <fo:table space-after.optimum="15pt">
  62. <fo:table-column column-width="1cm"/>
  63. <fo:table-column column-width="15cm"/>
  64. <fo:table-body font-size="10pt"
  65. font-family="sans-serif">
  66. <xsl:for-each select="div0/head">
  67. <fo:table-row line-height="12pt">
  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. <xsl:value-of select="."/>
  76. </fo:block>
  77. </fo:table-cell>
  78. </fo:table-row>
  79. </xsl:for-each>
  80. </fo:table-body>
  81. </fo:table>
  82. <xsl:apply-templates/>
  83. <fo:block font-size="10pt"
  84. font-family="sans-serif"
  85. line-height="11pt"
  86. space-before.optimum="2cm">
  87. The explanation of the flow objects is based (mostly verbatim) on the section
  88. 6.2 of the XSL W3C Candidate Recommendation 21 November 2000. More info at the beginning
  89. of the file xslfoRef.xml.
  90. </fo:block>
  91. </fo:flow>
  92. </fo:page-sequence>
  93. </fo:root>
  94. </xsl:template>
  95. <xsl:template match ="div">
  96. <fo:block font-size="14pt"
  97. font-family="sans-serif"
  98. space-before.optimum="3pt"
  99. space-after.optimum="3pt"
  100. text-align="center"
  101. padding-top="3pt"
  102. >
  103. <xsl:apply-templates/>
  104. </fo:block>
  105. </xsl:template>
  106. <xsl:template match ="div0/head">
  107. <fo:block font-size="16pt"
  108. line-height="18pt"
  109. text-align="center"
  110. padding-top="3pt"
  111. start-indent="2cm"
  112. end-indent="2cm"
  113. background-color="blue"
  114. color="white"
  115. space-before.optimum="5pt"
  116. space-after.optimum="5pt"
  117. >
  118. <xsl:value-of select="."/>
  119. </fo:block>
  120. </xsl:template>
  121. <xsl:template match ="div/fo">
  122. <fo:block font-size="13pt"
  123. line-height="14pt"
  124. text-align="start"
  125. >
  126. <xsl:value-of select="."/>
  127. </fo:block>
  128. </xsl:template>
  129. <xsl:template match ="explanation">
  130. <fo:block font-size="11pt"
  131. font-family="sans-serif"
  132. line-height="12pt"
  133. text-align="start"
  134. start-indent="0.5cm"
  135. >
  136. <xsl:apply-templates/>
  137. </fo:block>
  138. </xsl:template>
  139. <xsl:template match ="div/content">
  140. <fo:block font-size="10pt"
  141. font-family="Courier"
  142. start-indent="0.5cm"
  143. line-height="11pt"
  144. text-align="start"
  145. wrap-option="wrap">
  146. Content: <xsl:value-of select="."/>
  147. </fo:block>
  148. </xsl:template>
  149. <xsl:template match ="div/properties">
  150. <fo:block font-size="10pt"
  151. font-family="Courier"
  152. line-height="11pt"
  153. text-align="start"
  154. start-indent="0.5cm">
  155. Properties:
  156. </fo:block>
  157. <fo:block space-after.optimum="3pt">
  158. <xsl:apply-templates/>
  159. </fo:block>
  160. </xsl:template>
  161. <xsl:template match ="properties/property">
  162. <fo:block font-size="9pt"
  163. font-family="sans-serif"
  164. line-height="10pt"
  165. text-align="start"
  166. start-indent="1cm">
  167. <xsl:value-of select="."/>
  168. </fo:block>
  169. </xsl:template>
  170. <xsl:template match ="div/property-def">
  171. <fo:block font-size="13pt"
  172. line-height="14pt"
  173. text-align="start"
  174. >
  175. <xsl:value-of select="."/>
  176. </fo:block>
  177. </xsl:template>
  178. <xsl:template match ="div/values">
  179. <fo:block font-size="11pt"
  180. text-align="start"
  181. line-height="12pt">Values: <xsl:value-of select="."/>
  182. </fo:block>
  183. </xsl:template>
  184. </xsl:stylesheet>