fopdf.xsl 21 KB

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