lfs-pagesetup.xsl 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <?xml version='1.0' encoding='ISO-8859-1'?>
  2. <!--
  3. $LastChangedBy$
  4. $Date$
  5. -->
  6. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  7. xmlns:fo="http://www.w3.org/1999/XSL/Format"
  8. version="1.0">
  9. <!-- This stylesheet controls page margins, sections page break,
  10. header content and titles size. -->
  11. <!-- The inner page margin. -->
  12. <xsl:param name="page.margin.inner" select="'0.32in'"/>
  13. <!-- The outer page margin. -->
  14. <xsl:param name="page.margin.outer" select="'0.32in'"/>
  15. <!-- The bottom margin of the page. -->
  16. <xsl:param name="page.margin.bottom" select="'0.35in'"/>
  17. <!-- The top margin of the page. -->
  18. <xsl:param name="page.margin.top" select="'0.35in'"/>
  19. <!-- The bottom margin of the body text. -->
  20. <xsl:param name="body.margin.bottom" select="'0.4in'"/>
  21. <!-- The top margin of the body text. -->
  22. <xsl:param name="body.margin.top" select="'0.4in'"/>
  23. <!-- Specifies the height of the header. -->
  24. <xsl:param name="region.before.extent" select="'0.25in'"/>
  25. <!-- Specifies the height of the footer. -->
  26. <xsl:param name="region.after.extent" select="'0.25in'"/>
  27. <!-- The start-indent for the body text. -->
  28. <xsl:param name="body.start.indent" select="'0pc'"/>
  29. <!-- Adjust the left margin for titles. -->
  30. <xsl:param name="title.margin.left">-0.8pc</xsl:param>
  31. <!-- Default table width on tables that do not specify an alternate
  32. width using the dbfo processing instruction.
  33. This value is used also on bookinfo/revhistory table. -->
  34. <xsl:param name="default.table.width" select="'70%'"/>
  35. <!-- Properties for component titles -->
  36. <xsl:attribute-set name="component.title.properties">
  37. <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
  38. <xsl:attribute name="space-before.optimum">
  39. <xsl:value-of select="concat($body.font.master, 'pt')"/>
  40. </xsl:attribute>
  41. <xsl:attribute name="space-before.minimum">
  42. <xsl:value-of select="concat($body.font.master, 'pt * 0.8')"/>
  43. </xsl:attribute>
  44. <xsl:attribute name="space-before.maximum">
  45. <xsl:value-of select="concat($body.font.master, 'pt * 1.2')"/>
  46. </xsl:attribute>
  47. <xsl:attribute name="hyphenate">false</xsl:attribute>
  48. <xsl:attribute name="text-align">
  49. <xsl:choose>
  50. <xsl:when test="((parent::article | parent::articleinfo |
  51. parent::info/parent::article)
  52. and not(ancestor::book) and not(self::bibliography))
  53. or (parent::slides | parent::slidesinfo)
  54. or self::index">center</xsl:when>
  55. <xsl:otherwise>left</xsl:otherwise>
  56. </xsl:choose>
  57. </xsl:attribute>
  58. <xsl:attribute name="start-indent">
  59. <xsl:value-of select="$title.margin.left"/>
  60. </xsl:attribute>
  61. </xsl:attribute-set>
  62. <!-- Rule under headers? 1 =yes, 0 = no -->
  63. <xsl:param name="header.rule" select="0"/>
  64. <!-- Rule over footers? 1 =yes, 0 = no -->
  65. <xsl:param name="footer.rule" select="0"></xsl:param>
  66. <!-- Control depth of sections shown in running headers or footers.
  67. Be sure that no unneeded fo:marker are generated. -->
  68. <xsl:param name="marker.section.level" select="-1"></xsl:param>
  69. <!-- Force package's sect1 onto a new page -->
  70. <xsl:attribute-set name="section.level1.properties">
  71. <xsl:attribute name="break-before">
  72. <xsl:choose>
  73. <!--<xsl:when test="not(. = //*/sect1[1])">
  74. <xsl:text>page</xsl:text>
  75. </xsl:when>-->
  76. <xsl:when test="preceding-sibling::sect1[position()=1]/sect2/@role='package'
  77. or self::sect1/sect2/@role='package'">page</xsl:when>
  78. <xsl:otherwise>
  79. <xsl:text>auto</xsl:text>
  80. </xsl:otherwise>
  81. </xsl:choose>
  82. </xsl:attribute>
  83. </xsl:attribute-set>
  84. <!-- part/partintro:
  85. Be sure that partintro is on a new page. -->
  86. <!-- The original template is in {docbook-xsl}/fo/divisions.xsl -->
  87. <xsl:template match="part/partintro">
  88. <xsl:apply-templates select=".." mode="part.titlepage.mode">
  89. <xsl:with-param name="additional.content">
  90. <fo:block break-before="page"/>
  91. <xsl:if test="title">
  92. <xsl:call-template name="partintro.titlepage"/>
  93. </xsl:if>
  94. <xsl:apply-templates/>
  95. </xsl:with-param>
  96. </xsl:apply-templates>
  97. <xsl:call-template name="generate.part.toc">
  98. <xsl:with-param name="part" select=".."/>
  99. </xsl:call-template>
  100. </xsl:template>
  101. <!-- book title:
  102. Centered the title and removed unused code.
  103. Removed book.titlepage.separator. -->
  104. <!-- The original template is in {docbook-xsl}/fo/titlepage.templates.xsl -->
  105. <xsl:template name="book.titlepage">
  106. <fo:block margin-top="3in">
  107. <fo:block>
  108. <xsl:call-template name="book.titlepage.before.recto"/>
  109. <xsl:call-template name="book.titlepage.recto"/>
  110. </fo:block>
  111. <fo:block>
  112. <xsl:call-template name="book.titlepage.before.verso"/>
  113. <xsl:call-template name="book.titlepage.verso"/>
  114. </fo:block>
  115. </fo:block>
  116. </xsl:template>
  117. <!-- book titlepage verso:
  118. Added missing bibliosource and revhistory support.
  119. Removed unused code. -->
  120. <!-- The original template is in {docbook-xsl}/fo/titlepage.templates.xsl -->
  121. <xsl:template name="book.titlepage.verso">
  122. <xsl:apply-templates mode="book.titlepage.verso.auto.mode" select="bookinfo/title"/>
  123. <xsl:apply-templates mode="book.titlepage.verso.auto.mode" select="bookinfo/corpauthor"/>
  124. <xsl:apply-templates mode="book.titlepage.verso.auto.mode" select="bookinfo/authorgroup"/>
  125. <xsl:apply-templates mode="book.titlepage.verso.auto.mode" select="bookinfo/author"/>
  126. <xsl:apply-templates mode="book.titlepage.verso.auto.mode" select="bookinfo/othercredit"/>
  127. <xsl:apply-templates mode="book.titlepage.verso.auto.mode" select="bookinfo/releaseinfo"/>
  128. <xsl:apply-templates mode="book.titlepage.verso.auto.mode" select="bookinfo/pubdate"/>
  129. <xsl:apply-templates mode="book.titlepage.verso.auto.mode" select="bookinfo/copyright"/>
  130. <xsl:apply-templates mode="book.titlepage.verso.auto.mode" select="bookinfo/bibliosource"/>
  131. <xsl:apply-templates mode="book.titlepage.verso.auto.mode" select="bookinfo/abstract"/>
  132. <xsl:apply-templates mode="book.titlepage.verso.auto.mode" select="bookinfo/revhistory"/>
  133. <xsl:apply-templates mode="book.titlepage.verso.auto.mode" select="bookinfo/legalnotice"/>
  134. </xsl:template>
  135. <!-- bibliosource:
  136. Self-made template to handle bibliosource when inside bookinfo. -->
  137. <xsl:template match="bibliosource" mode="book.titlepage.verso.auto.mode">
  138. <fo:block font-size="8pt">
  139. <xsl:apply-templates/>
  140. </fo:block>
  141. </xsl:template>
  142. <!-- part title:
  143. Centered the title and removed unused code. -->
  144. <!-- The original template is in {docbook-xsl}/fo/titlepage.templates.xsl -->
  145. <xsl:template name="part.titlepage">
  146. <fo:block>
  147. <fo:block margin-top="3.5in">
  148. <xsl:call-template name="part.titlepage.before.recto"/>
  149. <xsl:call-template name="part.titlepage.recto"/>
  150. </fo:block>
  151. <fo:block>
  152. <xsl:call-template name="part.titlepage.before.verso"/>
  153. <xsl:call-template name="part.titlepage.verso"/>
  154. </fo:block>
  155. <xsl:call-template name="part.titlepage.separator"/>
  156. </fo:block>
  157. </xsl:template>
  158. <!-- chapter title:
  159. Small font size and left alignament. -->
  160. <!-- The original template is in {docbook-xsl}/fo/titlepage.templates.xsl -->
  161. <xsl:template match="title" mode="chapter.titlepage.recto.auto.mode">
  162. <fo:block xsl:use-attribute-sets="chapter.titlepage.recto.style"
  163. font-size="21pt" font-weight="bold" text-align="left">
  164. <xsl:call-template name="component.title">
  165. <xsl:with-param name="node" select="ancestor-or-self::chapter[1]"/>
  166. </xsl:call-template>
  167. </fo:block>
  168. </xsl:template>
  169. <!-- sect2 title:
  170. Skip sect2.titlepage run when title is empty.
  171. Removed unused code. -->
  172. <!-- The original template is in {docbook-xsl}/fo/sections.xsl -->
  173. <xsl:template match="sect2">
  174. <xsl:variable name="id">
  175. <xsl:call-template name="object.id"/>
  176. </xsl:variable>
  177. <fo:block xsl:use-attribute-sets="section.level2.properties">
  178. <xsl:attribute name="id">
  179. <xsl:value-of select="$id"/>
  180. </xsl:attribute>
  181. <xsl:if test="not(string-length(title)=0)">
  182. <xsl:call-template name="sect2.titlepage"/>
  183. </xsl:if>
  184. <xsl:apply-templates/>
  185. </fo:block>
  186. </xsl:template>
  187. <!-- header.table:
  188. Re-made template to not generate a fo:table in the header,
  189. allowing a more simple header.content customization. -->
  190. <!-- The original template is in {docbook-xsl}/fo/pagesetup.xsl -->
  191. <xsl:template name="header.table">
  192. <xsl:param name="sequence" select="''"/>
  193. <xsl:param name="gentext-key" select="''"/>
  194. <xsl:choose>
  195. <xsl:when test="$gentext-key = 'book' or $sequence = 'blank'"/>
  196. <xsl:otherwise>
  197. <xsl:call-template name="header.content">
  198. <xsl:with-param name="sequence" select="$sequence"/>
  199. </xsl:call-template>
  200. </xsl:otherwise>
  201. </xsl:choose>
  202. </xsl:template>
  203. <!-- header.content
  204. Re-made template to show the book title and version on all pages. -->
  205. <!-- The original template is in {docbook-xsl}/fo/pagesetup.xsl -->
  206. <xsl:template name="header.content">
  207. <xsl:param name="sequence" select="''"/>
  208. <fo:block>
  209. <xsl:attribute name="text-align">
  210. <xsl:choose>
  211. <xsl:when test="$sequence = 'first' or $sequence = 'odd'">right</xsl:when>
  212. <xsl:otherwise>left</xsl:otherwise>
  213. </xsl:choose>
  214. </xsl:attribute>
  215. <xsl:value-of select="/book/bookinfo/title"/>
  216. <xsl:text> - </xsl:text>
  217. <xsl:value-of select="/book/bookinfo/subtitle"/>
  218. </fo:block>
  219. </xsl:template>
  220. </xsl:stylesheet>