fopdf.xsl 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. <?xml version="1.0"?>
  2. <!--
  3. This is the XSL FO configuration file for the Hibernate
  4. Reference Documentation. It defines a custom titlepage and
  5. the parameters for the A4 sized PDF printable output.
  6. It took me days to figure out this stuff and fix most of
  7. the obvious bugs in the DocBook XSL distribution, so if you
  8. use this stylesheet, give some credit back to the Hibernate
  9. project.
  10. christian.bauer@bluemars.de
  11. -->
  12. <!DOCTYPE xsl:stylesheet [
  13. <!ENTITY db_xsl_path "../lib/docbook-xsl/">
  14. <!ENTITY admon_gfx_path "../images/admons/">
  15. ]>
  16. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  17. version="1.0"
  18. xmlns="http://www.w3.org/TR/xhtml1/transitional"
  19. xmlns:fo="http://www.w3.org/1999/XSL/Format"
  20. exclude-result-prefixes="#default">
  21. <xsl:import href="&db_xsl_path;/fo/docbook.xsl"/>
  22. <!--###################################################
  23. Custom Title Page
  24. ################################################### -->
  25. <xsl:template name="book.titlepage.recto">
  26. <fo:block>
  27. <fo:table table-layout="fixed" width="175mm">
  28. <fo:table-column column-width="175mm"/>
  29. <fo:table-body>
  30. <fo:table-row>
  31. <fo:table-cell text-align="center">
  32. <fo:block>
  33. <fo:external-graphic src="file:images/logo.gif"/>
  34. </fo:block>
  35. <fo:block font-family="Helvetica" font-size="22pt" padding-before="10mm">
  36. <xsl:value-of select="bookinfo/subtitle"/>
  37. </fo:block>
  38. <fo:block font-family="Helvetica" font-size="12pt" padding="10mm">
  39. Version: <xsl:value-of select="bookinfo/releaseinfo"/>
  40. </fo:block>
  41. </fo:table-cell>
  42. </fo:table-row>
  43. </fo:table-body>
  44. </fo:table>
  45. </fo:block>
  46. </xsl:template>
  47. <!-- Prevent blank pages in output -->
  48. <xsl:template name="book.titlepage.before.verso">
  49. </xsl:template>
  50. <xsl:template name="book.titlepage.verso">
  51. </xsl:template>
  52. <xsl:template name="book.titlepage.separator">
  53. </xsl:template>
  54. <!--###################################################
  55. Header
  56. ################################################### -->
  57. <!-- More space in the center header for long text -->
  58. <xsl:attribute-set name="header.content.properties">
  59. <xsl:attribute name="font-family">
  60. <xsl:value-of select="$body.font.family"/>
  61. </xsl:attribute>
  62. <xsl:attribute name="margin-left">-5em</xsl:attribute>
  63. <xsl:attribute name="margin-right">-5em</xsl:attribute>
  64. </xsl:attribute-set>
  65. <!--###################################################
  66. Custom Footer
  67. ################################################### -->
  68. <!-- This footer prints the version number on the left side -->
  69. <xsl:template name="footer.content">
  70. <xsl:param name="pageclass" select="''"/>
  71. <xsl:param name="sequence" select="''"/>
  72. <xsl:param name="position" select="''"/>
  73. <xsl:param name="gentext-key" select="''"/>
  74. <xsl:variable name="Version">
  75. <xsl:choose>
  76. <xsl:when test="//releaseinfo">
  77. <xsl:text>Acegi Security System for Spring </xsl:text><xsl:value-of select="//releaseinfo"/>
  78. </xsl:when>
  79. <xsl:otherwise>
  80. <!-- nop -->
  81. </xsl:otherwise>
  82. </xsl:choose>
  83. </xsl:variable>
  84. <xsl:choose>
  85. <xsl:when test="$sequence='blank'">
  86. <xsl:choose>
  87. <xsl:when test="$double.sided != 0 and $position = 'left'">
  88. <xsl:value-of select="$Version"/>
  89. </xsl:when>
  90. <xsl:when test="$double.sided = 0 and $position = 'center'">
  91. <!-- nop -->
  92. </xsl:when>
  93. <xsl:otherwise>
  94. <fo:page-number/>
  95. </xsl:otherwise>
  96. </xsl:choose>
  97. </xsl:when>
  98. <xsl:when test="$pageclass='titlepage'">
  99. <!-- nop: other titlepage sequences have no footer -->
  100. </xsl:when>
  101. <xsl:when test="$double.sided != 0 and $sequence = 'even' and $position='left'">
  102. <fo:page-number/>
  103. </xsl:when>
  104. <xsl:when test="$double.sided != 0 and $sequence = 'odd' and $position='right'">
  105. <fo:page-number/>
  106. </xsl:when>
  107. <xsl:when test="$double.sided = 0 and $position='right'">
  108. <fo:page-number/>
  109. </xsl:when>
  110. <xsl:when test="$double.sided != 0 and $sequence = 'odd' and $position='left'">
  111. <xsl:value-of select="$Version"/>
  112. </xsl:when>
  113. <xsl:when test="$double.sided != 0 and $sequence = 'even' and $position='right'">
  114. <xsl:value-of select="$Version"/>
  115. </xsl:when>
  116. <xsl:when test="$double.sided = 0 and $position='left'">
  117. <xsl:value-of select="$Version"/>
  118. </xsl:when>
  119. <xsl:otherwise>
  120. <!-- nop -->
  121. </xsl:otherwise>
  122. </xsl:choose>
  123. </xsl:template>
  124. <!--###################################################
  125. Custom Toc Line
  126. ################################################### -->
  127. <!-- The default DocBook XSL TOC printing is seriously broken... -->
  128. <xsl:template name="toc.line">
  129. <xsl:variable name="id">
  130. <xsl:call-template name="object.id"/>
  131. </xsl:variable>
  132. <xsl:variable name="label">
  133. <xsl:apply-templates select="." mode="label.markup"/>
  134. </xsl:variable>
  135. <!-- justify-end removed from block attributes (space problem in title.markup) -->
  136. <fo:block end-indent="{$toc.indent.width}pt"
  137. last-line-end-indent="-{$toc.indent.width}pt"
  138. white-space-treatment="preserve"
  139. white-space-collapse="false">
  140. <fo:inline keep-with-next.within-line="always">
  141. <!-- print Chapters in bold style -->
  142. <xsl:choose>
  143. <xsl:when test="local-name(.) = 'chapter'">
  144. <xsl:attribute name="font-weight">bold</xsl:attribute>
  145. </xsl:when>
  146. </xsl:choose>
  147. <fo:basic-link internal-destination="{$id}">
  148. <xsl:if test="$label != ''">
  149. <xsl:copy-of select="$label"/>
  150. <fo:inline white-space-treatment="preserve"
  151. white-space-collapse="false">
  152. <xsl:value-of select="$autotoc.label.separator"/>
  153. </fo:inline>
  154. </xsl:if>
  155. <xsl:apply-templates select="." mode="title.markup"/>
  156. </fo:basic-link>
  157. </fo:inline>
  158. <fo:inline keep-together.within-line="always">
  159. <xsl:text> </xsl:text>
  160. <fo:leader leader-pattern="dots"
  161. leader-pattern-width="3pt"
  162. leader-alignment="reference-area"
  163. keep-with-next.within-line="always"/>
  164. <xsl:text> </xsl:text>
  165. <fo:basic-link internal-destination="{$id}">
  166. <fo:page-number-citation ref-id="{$id}"/>
  167. </fo:basic-link>
  168. </fo:inline>
  169. </fo:block>
  170. </xsl:template>
  171. <!--###################################################
  172. Extensions
  173. ################################################### -->
  174. <!-- These extensions are required for table printing and other stuff -->
  175. <xsl:param name="use.extensions">1</xsl:param>
  176. <xsl:param name="tablecolumns.extension">0</xsl:param>
  177. <xsl:param name="callout.extensions">1</xsl:param>
  178. <!-- FOP provide only PDF Bookmarks at the moment -->
  179. <xsl:param name="fop.extensions">1</xsl:param>
  180. <!--###################################################
  181. Table Of Contents
  182. ################################################### -->
  183. <!-- Generate the TOCs for named components only -->
  184. <xsl:param name="generate.toc">
  185. book toc
  186. </xsl:param>
  187. <!-- Show only Sections up to level 3 in the TOCs -->
  188. <xsl:param name="toc.section.depth">2</xsl:param>
  189. <!-- Dot and Whitespace as separator in TOC between Label and Title-->
  190. <xsl:param name="autotoc.label.separator" select="'. '"/>
  191. <!--###################################################
  192. Paper & Page Size
  193. ################################################### -->
  194. <!-- Paper type, no headers on blank pages, no double sided printing -->
  195. <xsl:param name="paper.type" select="'A4'"/>
  196. <xsl:param name="double.sided">0</xsl:param>
  197. <xsl:param name="headers.on.blank.pages">0</xsl:param>
  198. <xsl:param name="footers.on.blank.pages">0</xsl:param>
  199. <!-- Space between paper border and content (chaotic stuff, don't touch) -->
  200. <xsl:param name="page.margin.top">5mm</xsl:param>
  201. <xsl:param name="region.before.extent">10mm</xsl:param>
  202. <xsl:param name="body.margin.top">10mm</xsl:param>
  203. <xsl:param name="body.margin.bottom">15mm</xsl:param>
  204. <xsl:param name="region.after.extent">10mm</xsl:param>
  205. <xsl:param name="page.margin.bottom">0mm</xsl:param>
  206. <xsl:param name="page.margin.outer">18mm</xsl:param>
  207. <xsl:param name="page.margin.inner">18mm</xsl:param>
  208. <!-- No intendation of Titles -->
  209. <xsl:param name="title.margin.left">0pc</xsl:param>
  210. <!--###################################################
  211. Fonts & Styles
  212. ################################################### -->
  213. <!-- Default Font size -->
  214. <xsl:param name="body.font.master">11</xsl:param>
  215. <xsl:param name="body.font.small">8</xsl:param>
  216. <!-- Line height in body text -->
  217. <xsl:param name="line-height">1.4</xsl:param>
  218. <!-- Monospaced fonts are smaller than regular text -->
  219. <xsl:attribute-set name="monospace.properties">
  220. <xsl:attribute name="font-family">
  221. <xsl:value-of select="$monospace.font.family"/>
  222. </xsl:attribute>
  223. <xsl:attribute name="font-size">0.8em</xsl:attribute>
  224. </xsl:attribute-set>
  225. <!--###################################################
  226. Tables
  227. ################################################### -->
  228. <!-- The table width should be adapted to the paper size -->
  229. <xsl:param name="default.table.width">17.4cm</xsl:param>
  230. <!-- Some padding inside tables -->
  231. <xsl:attribute-set name="table.cell.padding">
  232. <xsl:attribute name="padding-left">4pt</xsl:attribute>
  233. <xsl:attribute name="padding-right">4pt</xsl:attribute>
  234. <xsl:attribute name="padding-top">4pt</xsl:attribute>
  235. <xsl:attribute name="padding-bottom">4pt</xsl:attribute>
  236. </xsl:attribute-set>
  237. <!-- Only hairlines as frame and cell borders in tables -->
  238. <xsl:param name="table.frame.border.thickness">0.1pt</xsl:param>
  239. <xsl:param name="table.cell.border.thickness">0.1pt</xsl:param>
  240. <!--###################################################
  241. Labels
  242. ################################################### -->
  243. <!-- Label Chapters and Sections (numbering) -->
  244. <xsl:param name="chapter.autolabel">1</xsl:param>
  245. <xsl:param name="section.autolabel" select="1"/>
  246. <xsl:param name="section.label.includes.component.label" select="1"/>
  247. <!--###################################################
  248. Titles
  249. ################################################### -->
  250. <!-- Chapter title size -->
  251. <xsl:attribute-set name="chapter.titlepage.recto.style">
  252. <xsl:attribute name="text-align">left</xsl:attribute>
  253. <xsl:attribute name="font-weight">bold</xsl:attribute>
  254. <xsl:attribute name="font-size">
  255. <xsl:value-of select="$body.font.master * 1.8"/>
  256. <xsl:text>pt</xsl:text>
  257. </xsl:attribute>
  258. </xsl:attribute-set>
  259. <!-- Why is the font-size for chapters hardcoded in the XSL FO templates?
  260. Let's remove it, so this sucker can use our attribute-set only... -->
  261. <xsl:template match="title" mode="chapter.titlepage.recto.auto.mode">
  262. <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format"
  263. xsl:use-attribute-sets="chapter.titlepage.recto.style">
  264. <xsl:call-template name="component.title">
  265. <xsl:with-param name="node" select="ancestor-or-self::chapter[1]"/>
  266. </xsl:call-template>
  267. </fo:block>
  268. </xsl:template>
  269. <!-- Sections 1, 2 and 3 titles have a small bump factor and padding -->
  270. <xsl:attribute-set name="section.title.level1.properties">
  271. <xsl:attribute name="space-before.optimum">0.8em</xsl:attribute>
  272. <xsl:attribute name="space-before.minimum">0.8em</xsl:attribute>
  273. <xsl:attribute name="space-before.maximum">0.8em</xsl:attribute>
  274. <xsl:attribute name="font-size">
  275. <xsl:value-of select="$body.font.master * 1.5"/>
  276. <xsl:text>pt</xsl:text>
  277. </xsl:attribute>
  278. <xsl:attribute name="space-after.optimum">0.1em</xsl:attribute>
  279. <xsl:attribute name="space-after.minimum">0.1em</xsl:attribute>
  280. <xsl:attribute name="space-after.maximum">0.1em</xsl:attribute>
  281. </xsl:attribute-set>
  282. <xsl:attribute-set name="section.title.level2.properties">
  283. <xsl:attribute name="space-before.optimum">0.6em</xsl:attribute>
  284. <xsl:attribute name="space-before.minimum">0.6em</xsl:attribute>
  285. <xsl:attribute name="space-before.maximum">0.6em</xsl:attribute>
  286. <xsl:attribute name="font-size">
  287. <xsl:value-of select="$body.font.master * 1.25"/>
  288. <xsl:text>pt</xsl:text>
  289. </xsl:attribute>
  290. <xsl:attribute name="space-after.optimum">0.1em</xsl:attribute>
  291. <xsl:attribute name="space-after.minimum">0.1em</xsl:attribute>
  292. <xsl:attribute name="space-after.maximum">0.1em</xsl:attribute>
  293. </xsl:attribute-set>
  294. <xsl:attribute-set name="section.title.level3.properties">
  295. <xsl:attribute name="space-before.optimum">0.4em</xsl:attribute>
  296. <xsl:attribute name="space-before.minimum">0.4em</xsl:attribute>
  297. <xsl:attribute name="space-before.maximum">0.4em</xsl:attribute>
  298. <xsl:attribute name="font-size">
  299. <xsl:value-of select="$body.font.master * 1.0"/>
  300. <xsl:text>pt</xsl:text>
  301. </xsl:attribute>
  302. <xsl:attribute name="space-after.optimum">0.1em</xsl:attribute>
  303. <xsl:attribute name="space-after.minimum">0.1em</xsl:attribute>
  304. <xsl:attribute name="space-after.maximum">0.1em</xsl:attribute>
  305. </xsl:attribute-set>
  306. <!-- Titles of formal objects (tables, examples, ...) -->
  307. <xsl:attribute-set name="formal.title.properties" use-attribute-sets="normal.para.spacing">
  308. <xsl:attribute name="font-weight">bold</xsl:attribute>
  309. <xsl:attribute name="font-size">
  310. <xsl:value-of select="$body.font.master"/>
  311. <xsl:text>pt</xsl:text>
  312. </xsl:attribute>
  313. <xsl:attribute name="hyphenate">false</xsl:attribute>
  314. <xsl:attribute name="space-after.minimum">0.4em</xsl:attribute>
  315. <xsl:attribute name="space-after.optimum">0.6em</xsl:attribute>
  316. <xsl:attribute name="space-after.maximum">0.8em</xsl:attribute>
  317. </xsl:attribute-set>
  318. <!--###################################################
  319. Programlistings
  320. ################################################### -->
  321. <!-- Verbatim text formatting (programlistings) -->
  322. <xsl:attribute-set name="monospace.verbatim.properties">
  323. <xsl:attribute name="font-size">
  324. <xsl:value-of select="$body.font.small * 1.0"/>
  325. <xsl:text>pt</xsl:text>
  326. </xsl:attribute>
  327. </xsl:attribute-set>
  328. <xsl:attribute-set name="verbatim.properties">
  329. <xsl:attribute name="space-before.minimum">1em</xsl:attribute>
  330. <xsl:attribute name="space-before.optimum">1em</xsl:attribute>
  331. <xsl:attribute name="space-before.maximum">1em</xsl:attribute>
  332. <!-- alef: commented out because footnotes were screwed because of it -->
  333. <!--<xsl:attribute name="space-after.minimum">0.1em</xsl:attribute>
  334. <xsl:attribute name="space-after.optimum">0.1em</xsl:attribute>
  335. <xsl:attribute name="space-after.maximum">0.1em</xsl:attribute>-->
  336. <xsl:attribute name="border-color">#444444</xsl:attribute>
  337. <xsl:attribute name="border-style">solid</xsl:attribute>
  338. <xsl:attribute name="border-width">0.1pt</xsl:attribute>
  339. <xsl:attribute name="padding-top">0.5em</xsl:attribute>
  340. <xsl:attribute name="padding-left">0.5em</xsl:attribute>
  341. <xsl:attribute name="padding-right">0.5em</xsl:attribute>
  342. <xsl:attribute name="padding-bottom">0.5em</xsl:attribute>
  343. <xsl:attribute name="margin-left">0.5em</xsl:attribute>
  344. <xsl:attribute name="margin-right">0.5em</xsl:attribute>
  345. </xsl:attribute-set>
  346. <!-- Shade (background) programlistings -->
  347. <xsl:param name="shade.verbatim">1</xsl:param>
  348. <xsl:attribute-set name="shade.verbatim.style">
  349. <xsl:attribute name="background-color">#F0F0F0</xsl:attribute>
  350. </xsl:attribute-set>
  351. <!--###################################################
  352. Callouts
  353. ################################################### -->
  354. <!-- Use images for callouts instead of (1) (2) (3) -->
  355. <xsl:param name="callout.graphics">0</xsl:param>
  356. <xsl:param name="callout.unicode">1</xsl:param>
  357. <!-- Place callout marks at this column in annotated areas -->
  358. <xsl:param name="callout.defaultcolumn">90</xsl:param>
  359. <!--###################################################
  360. Admonitions
  361. ################################################### -->
  362. <!-- Use nice graphics for admonitions -->
  363. <xsl:param name="admon.graphics">'1'</xsl:param>
  364. <xsl:param name="admon.graphics.path">&admon_gfx_path;</xsl:param>
  365. <!--###################################################
  366. Misc
  367. ################################################### -->
  368. <!-- Placement of titles -->
  369. <xsl:param name="formal.title.placement">
  370. figure after
  371. example before
  372. equation before
  373. table before
  374. procedure before
  375. </xsl:param>
  376. <!-- Format Variable Lists as Blocks (prevents horizontal overflow) -->
  377. <xsl:param name="variablelist.as.blocks">1</xsl:param>
  378. <!-- The horrible list spacing problems -->
  379. <xsl:attribute-set name="list.block.spacing">
  380. <xsl:attribute name="space-before.optimum">0.8em</xsl:attribute>
  381. <xsl:attribute name="space-before.minimum">0.8em</xsl:attribute>
  382. <xsl:attribute name="space-before.maximum">0.8em</xsl:attribute>
  383. <xsl:attribute name="space-after.optimum">0.1em</xsl:attribute>
  384. <xsl:attribute name="space-after.minimum">0.1em</xsl:attribute>
  385. <xsl:attribute name="space-after.maximum">0.1em</xsl:attribute>
  386. </xsl:attribute-set>
  387. </xsl:stylesheet>