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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <?xml version="1.0"?>
  2. <!-- XSLT stylesheet: QAML -> FO (QAML = FAQ Markup Language)
  3. version: 1.00ß
  4. -->
  5. <xsl:stylesheet
  6. xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
  7. xmlns:fo="http://www.w3.org/1999/XSL/Format"
  8. result-ns="fo" indent-result="yes">
  9. <xsl:output indent="yes"/>
  10. <xsl:template match ="/">
  11. <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
  12. <!-- definiert die Druckseiten -->
  13. <fo:layout-master-set>
  14. <fo:simple-page-master page-master-name="first"
  15. height="29.7cm" width="21cm"
  16. margin-top="1cm" margin-bottom="2cm"
  17. margin-left="2.5cm" margin-right="2.5cm">
  18. <fo:region-before extent="3cm"/>
  19. <fo:region-body margin-top="3cm"/>
  20. <fo:region-after extent="1.5cm"/>
  21. </fo:simple-page-master>
  22. <fo:simple-page-master page-master-name="rest"
  23. height="29.7cm" width="21cm"
  24. margin-top="1cm" margin-bottom="2cm"
  25. margin-left="2.5cm" margin-right="2.5cm">
  26. <fo:region-before extent="2.5cm"/>
  27. <fo:region-body margin-top="2.5cm"/>
  28. <fo:region-after extent="1.5cm"/>
  29. </fo:simple-page-master>
  30. </fo:layout-master-set>
  31. <fo:page-sequence>
  32. <fo:sequence-specification>
  33. <fo:sequence-specifier-repeating page-master-first="first"
  34. page-master-repeating="rest"/>
  35. </fo:sequence-specification>
  36. <fo:static-content flow-name="xsl-before">
  37. <fo:block text-align="end"
  38. font-size="10pt"
  39. font-family="serif"
  40. line-height="14pt" >
  41. FOP - p. <fo:page-number/>
  42. </fo:block>
  43. </fo:static-content>
  44. <fo:flow flow-name="xsl-body">
  45. <xsl:apply-templates select="faq"/>
  46. </fo:flow>
  47. </fo:page-sequence>
  48. </fo:root>
  49. </xsl:template>
  50. <!-- don't output head -->
  51. <xsl:template match ="head">
  52. </xsl:template>
  53. <!-- body -->
  54. <xsl:template match ="body">
  55. <!-- defines text title -->
  56. <fo:block font-size="24pt"
  57. font-family="serif"
  58. line-height="24pt"
  59. space-after.optimum="15pt">
  60. <xsl:value-of select="//head/title"/>
  61. </fo:block>
  62. <!-- processing of the rest -->
  63. <xsl:apply-templates/>
  64. </xsl:template>
  65. <!-- title level1, numbering is generated -->
  66. <xsl:template match ="section[@class='level1']/title">
  67. <fo:block font-size="18pt"
  68. font-family="serif"
  69. line-height="20pt"
  70. space-before.optimum="20pt"
  71. space-after.optimum="14pt"
  72. keep-with-next="true">
  73. <xsl:number count="section[@class='level1']"/>)
  74. <xsl:apply-templates/>
  75. </fo:block>
  76. </xsl:template>
  77. <!-- title level2 -->
  78. <xsl:template match ="section[@class='level2']/title">
  79. <fo:block font-size="16pt"
  80. font-family="serif"
  81. line-height="18pt"
  82. space-before.optimum="8pt"
  83. space-after.optimum="8pt"
  84. keep-with-next="true">
  85. <xsl:apply-templates/>
  86. </fo:block>
  87. </xsl:template>
  88. <!-- title level3 -->
  89. <xsl:template match ="section[@class='level3']/title">
  90. <fo:block font-size="14pt"
  91. font-family="serif"
  92. line-height="16pt"
  93. space-before.optimum="8pt"
  94. space-after.optimum="4pt"
  95. keep-with-next="true">
  96. <xsl:apply-templates/>
  97. </fo:block>
  98. </xsl:template>
  99. <xsl:template match ="section">
  100. <xsl:apply-templates/>
  101. </xsl:template>
  102. <!-- question group -->
  103. <xsl:template match ="qna">
  104. <xsl:apply-templates/>
  105. </xsl:template>
  106. <!-- question -->
  107. <xsl:template match ="q">
  108. <fo:block start-indent="0.7cm"
  109. space-before.optimum="12pt">
  110. <xsl:value-of select="."/>
  111. </fo:block>
  112. </xsl:template>
  113. <!-- para in answer -->
  114. <xsl:template match ="a/p">
  115. <fo:block start-indent="0.7cm">
  116. <xsl:apply-templates/>
  117. </fo:block>
  118. </xsl:template>
  119. <!-- list -->
  120. <xsl:template match ="div[@class='list']">
  121. <fo:list-block start-indent="1cm"
  122. provisional-label-separation="3pt"
  123. provisional-distance-between-starts="6pt">
  124. <xsl:apply-templates/>
  125. </fo:list-block>
  126. </xsl:template>
  127. <!-- list items -->
  128. <xsl:template match ="div/p[@class='li']">
  129. <fo:list-item>
  130. <fo:list-item-label><fo:block>*</fo:block></fo:list-item-label>
  131. <fo:list-item-body>
  132. <fo:block>
  133. <xsl:apply-templates/>
  134. </fo:block>
  135. </fo:list-item-body>
  136. </fo:list-item>
  137. </xsl:template>
  138. <!-- code fragments, marked by attribute pre -->
  139. <xsl:template match ="section/p[@class='pre']">
  140. <fo:block font-size="10pt"
  141. font-family="monospace"
  142. line-height="12pt"
  143. space-before.optimum="3pt"
  144. space-after.optimum="3pt">
  145. <xsl:apply-templates/>
  146. </fo:block>
  147. </xsl:template>
  148. <!-- normal paras without class attribute -->
  149. <xsl:template match ="section/p[not(@class)]">
  150. <fo:block space-after.optimum="3pt">
  151. <xsl:apply-templates/>
  152. </fo:block>
  153. </xsl:template>
  154. <!-- link -->
  155. <xsl:template match ="link">
  156. <fo:inline-sequence font-style="italic"
  157. font-family="sans-serif">
  158. <xsl:apply-templates/>
  159. </fo:inline-sequence>
  160. (<xsl:value-of select="@href"/>)
  161. </xsl:template>
  162. </xsl:stylesheet>