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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <xsl:stylesheet
  2. xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  3. xmlns:fo="http://www.w3.org/1999/XSL/Format">
  4. <xsl:template match ="root">
  5. <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
  6. <!-- defines page layout -->
  7. <fo:layout-master-set>
  8. <fo:simple-page-master master-name="simple"
  9. page-height="29.7cm"
  10. page-width="21cm"
  11. margin-top="1.5cm"
  12. margin-bottom="1.5cm"
  13. margin-left="2.5cm"
  14. margin-right="2.5cm">
  15. <fo:region-body margin-top="1.5cm"/>
  16. <fo:region-before extent="1.5cm"/>
  17. <fo:region-after extent="1.5cm"/>
  18. </fo:simple-page-master>
  19. </fo:layout-master-set>
  20. <fo:page-sequence master-reference="simple">
  21. <fo:static-content flow-name="xsl-region-before">
  22. <fo:block text-align="end"
  23. font-size="10pt"
  24. font-family="serif"
  25. line-height="14pt" >
  26. xsl:fo short reference - p. <fo:page-number/>
  27. </fo:block>
  28. </fo:static-content>
  29. <fo:flow flow-name="xsl-region-body">
  30. <fo:block font-size="18pt"
  31. font-family="sans-serif"
  32. line-height="24pt"
  33. space-after.optimum="15pt"
  34. background-color="blue"
  35. color="white"
  36. text-align="center">
  37. xsl:fo short reference
  38. </fo:block>
  39. <!-- generates table of contents and puts it into a table -->
  40. <fo:block font-size="10pt"
  41. font-family="sans-serif"
  42. line-height="10pt"
  43. space-after.optimum="3pt"
  44. font-weight="bold"
  45. start-indent="15pt">
  46. Content
  47. </fo:block>
  48. <fo:table space-after.optimum="15pt">
  49. <fo:table-column column-width="1cm"/>
  50. <fo:table-column column-width="15cm"/>
  51. <fo:table-body font-size="10pt"
  52. font-family="sans-serif">
  53. <xsl:for-each select="div0/head">
  54. <fo:table-row line-height="12pt">
  55. <fo:table-cell>
  56. <fo:block text-align="end" >
  57. <xsl:number value="position()" format="1"/>)
  58. </fo:block>
  59. </fo:table-cell>
  60. <fo:table-cell>
  61. <fo:block text-align="start" >
  62. <xsl:value-of select="."/>
  63. </fo:block>
  64. </fo:table-cell>
  65. </fo:table-row>
  66. </xsl:for-each>
  67. </fo:table-body>
  68. </fo:table>
  69. <xsl:apply-templates/>
  70. <fo:block font-size="10pt"
  71. font-family="sans-serif"
  72. line-height="11pt"
  73. space-before.optimum="2cm">
  74. The explanation of the flow objects is based (mostly verbatim) on the section
  75. 6.2 of the XSL W3C Candidate Recommendation 21 November 2000. More info at the beginning
  76. of the file xslfoRef.xml.
  77. </fo:block>
  78. </fo:flow>
  79. </fo:page-sequence>
  80. </fo:root>
  81. </xsl:template>
  82. <xsl:template match ="div">
  83. <fo:block font-size="14pt"
  84. font-family="sans-serif"
  85. space-before.optimum="3pt"
  86. space-after.optimum="3pt"
  87. text-align="center"
  88. padding-top="3pt"
  89. >
  90. <xsl:apply-templates/>
  91. </fo:block>
  92. </xsl:template>
  93. <xsl:template match ="div0/head">
  94. <fo:block font-size="16pt"
  95. line-height="18pt"
  96. text-align="center"
  97. padding-top="3pt"
  98. start-indent="2cm"
  99. end-indent="2cm"
  100. background-color="blue"
  101. color="white"
  102. space-before.optimum="5pt"
  103. space-after.optimum="5pt"
  104. >
  105. <xsl:value-of select="."/>
  106. </fo:block>
  107. </xsl:template>
  108. <xsl:template match ="div/fo">
  109. <fo:block font-size="13pt"
  110. line-height="14pt"
  111. text-align="start"
  112. >
  113. <xsl:value-of select="."/>
  114. </fo:block>
  115. </xsl:template>
  116. <xsl:template match ="explanation">
  117. <fo:block font-size="11pt"
  118. font-family="sans-serif"
  119. line-height="12pt"
  120. text-align="start"
  121. start-indent="0.5cm"
  122. >
  123. <xsl:apply-templates/>
  124. </fo:block>
  125. </xsl:template>
  126. <xsl:template match ="div/content">
  127. <fo:block font-size="10pt"
  128. font-family="Courier"
  129. start-indent="0.5cm"
  130. line-height="11pt"
  131. text-align="start"
  132. wrap-option="wrap">
  133. Content: <xsl:value-of select="."/>
  134. </fo:block>
  135. </xsl:template>
  136. <xsl:template match ="div/properties">
  137. <fo:block font-size="10pt"
  138. font-family="Courier"
  139. line-height="11pt"
  140. text-align="start"
  141. start-indent="0.5cm">
  142. Properties:
  143. </fo:block>
  144. <fo:block space-after.optimum="3pt">
  145. <xsl:apply-templates/>
  146. </fo:block>
  147. </xsl:template>
  148. <xsl:template match ="properties/property">
  149. <fo:block font-size="9pt"
  150. font-family="sans-serif"
  151. line-height="10pt"
  152. text-align="start"
  153. start-indent="1cm">
  154. <xsl:value-of select="."/>
  155. </fo:block>
  156. </xsl:template>
  157. <xsl:template match ="div/property-def">
  158. <fo:block font-size="13pt"
  159. line-height="14pt"
  160. text-align="start"
  161. >
  162. <xsl:value-of select="."/>
  163. </fo:block>
  164. </xsl:template>
  165. <xsl:template match ="div/values">
  166. <fo:block font-size="11pt"
  167. text-align="start"
  168. line-height="12pt">Values: <xsl:value-of select="."/>
  169. </fo:block>
  170. </xsl:template>
  171. </xsl:stylesheet>