lfs-pagesetup.xsl 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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 unneeded 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. Removed book.titlepage.separator. -->
  100. <!-- The original template is in {docbook-xsl}/fo/titlepage.templates.xsl -->
  101. <xsl:template name="book.titlepage">
  102. <fo:block margin-top="3in">
  103. <fo:block>
  104. <xsl:call-template name="book.titlepage.before.recto"/>
  105. <xsl:call-template name="book.titlepage.recto"/>
  106. </fo:block>
  107. <fo:block>
  108. <xsl:call-template name="book.titlepage.before.verso"/>
  109. <xsl:call-template name="book.titlepage.verso"/>
  110. </fo:block>
  111. </fo:block>
  112. </xsl:template>
  113. <!-- book titlepage verso:
  114. Added missing bibliosource and revhistory support.
  115. Removed unused code. -->
  116. <!-- The original template is in {docbook-xsl}/fo/titlepage.templates.xsl -->
  117. <xsl:template name="book.titlepage.verso">
  118. <xsl:apply-templates mode="book.titlepage.verso.auto.mode" select="bookinfo/title"/>
  119. <xsl:apply-templates mode="book.titlepage.verso.auto.mode" select="bookinfo/corpauthor"/>
  120. <xsl:apply-templates mode="book.titlepage.verso.auto.mode" select="bookinfo/authorgroup"/>
  121. <xsl:apply-templates mode="book.titlepage.verso.auto.mode" select="bookinfo/author"/>
  122. <xsl:apply-templates mode="book.titlepage.verso.auto.mode" select="bookinfo/othercredit"/>
  123. <xsl:apply-templates mode="book.titlepage.verso.auto.mode" select="bookinfo/releaseinfo"/>
  124. <xsl:apply-templates mode="book.titlepage.verso.auto.mode" select="bookinfo/pubdate"/>
  125. <xsl:apply-templates mode="book.titlepage.verso.auto.mode" select="bookinfo/copyright"/>
  126. <xsl:apply-templates mode="book.titlepage.verso.auto.mode" select="bookinfo/bibliosource"/>
  127. <xsl:apply-templates mode="book.titlepage.verso.auto.mode" select="bookinfo/abstract"/>
  128. <xsl:apply-templates mode="book.titlepage.verso.auto.mode" select="bookinfo/revhistory"/>
  129. <xsl:apply-templates mode="book.titlepage.verso.auto.mode" select="bookinfo/legalnotice"/>
  130. </xsl:template>
  131. <!-- bibliosource:
  132. Self-made template to handle bibliosource when inside bookinfo. -->
  133. <xsl:template match="bibliosource" mode="book.titlepage.verso.auto.mode">
  134. <fo:block font-size="8pt">
  135. <xsl:apply-templates/>
  136. </fo:block>
  137. </xsl:template>
  138. <!-- part title:
  139. Centered the title and removed unused code. -->
  140. <!-- The original template is in {docbook-xsl}/fo/titlepage.templates.xsl -->
  141. <xsl:template name="part.titlepage">
  142. <fo:block>
  143. <fo:block margin-top="3.5in">
  144. <xsl:call-template name="part.titlepage.before.recto"/>
  145. <xsl:call-template name="part.titlepage.recto"/>
  146. </fo:block>
  147. <fo:block>
  148. <xsl:call-template name="part.titlepage.before.verso"/>
  149. <xsl:call-template name="part.titlepage.verso"/>
  150. </fo:block>
  151. <xsl:call-template name="part.titlepage.separator"/>
  152. </fo:block>
  153. </xsl:template>
  154. <!-- chapter title:
  155. Small font size and left alignament. -->
  156. <!-- The original template is in {docbook-xsl}/fo/titlepage.templates.xsl -->
  157. <xsl:template match="title" mode="chapter.titlepage.recto.auto.mode">
  158. <fo:block xsl:use-attribute-sets="chapter.titlepage.recto.style"
  159. font-size="21pt" font-weight="bold" text-align="left">
  160. <xsl:call-template name="component.title">
  161. <xsl:with-param name="node" select="ancestor-or-self::chapter[1]"/>
  162. </xsl:call-template>
  163. </fo:block>
  164. </xsl:template>
  165. <!-- sect2 title:
  166. Skip sect2.titlepage run when title is empty.
  167. Removed unused code. -->
  168. <!-- The original template is in {docbook-xsl}/fo/sections.xsl -->
  169. <xsl:template match="sect2">
  170. <xsl:variable name="id">
  171. <xsl:call-template name="object.id"/>
  172. </xsl:variable>
  173. <fo:block xsl:use-attribute-sets="section.level2.properties">
  174. <xsl:attribute name="id">
  175. <xsl:value-of select="$id"/>
  176. </xsl:attribute>
  177. <xsl:if test="not(string-length(title)=0)">
  178. <xsl:call-template name="sect2.titlepage"/>
  179. </xsl:if>
  180. <xsl:apply-templates/>
  181. </fo:block>
  182. </xsl:template>
  183. <!-- header.table:
  184. Re-made template to not generate a fo:table in the header,
  185. allowing a more simple header.content customization. -->
  186. <!-- The original template is in {docbook-xsl}/fo/pagesetup.xsl -->
  187. <xsl:template name="header.table">
  188. <xsl:param name="sequence" select="''"/>
  189. <xsl:param name="gentext-key" select="''"/>
  190. <xsl:choose>
  191. <xsl:when test="$gentext-key = 'book' or $sequence = 'blank'"/>
  192. <xsl:otherwise>
  193. <xsl:call-template name="header.content">
  194. <xsl:with-param name="sequence" select="$sequence"/>
  195. </xsl:call-template>
  196. </xsl:otherwise>
  197. </xsl:choose>
  198. </xsl:template>
  199. <!-- header.content
  200. Re-made template to show the book title and version on all pages. -->
  201. <!-- The original template is in {docbook-xsl}/fo/pagesetup.xsl -->
  202. <xsl:template name="header.content">
  203. <xsl:param name="sequence" select="''"/>
  204. <fo:block>
  205. <xsl:attribute name="text-align">
  206. <xsl:choose>
  207. <xsl:when test="$sequence = 'first' or $sequence = 'odd'">right</xsl:when>
  208. <xsl:otherwise>left</xsl:otherwise>
  209. </xsl:choose>
  210. </xsl:attribute>
  211. <xsl:value-of select="/book/bookinfo/title"/>
  212. <xsl:text> - </xsl:text>
  213. <xsl:value-of select="/book/bookinfo/subtitle"/>
  214. </fo:block>
  215. </xsl:template>
  216. </xsl:stylesheet>