lfs-pagesetup.xsl 8.3 KB

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