lfs-pagesetup.xsl 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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.5in'"/>
  9. <!-- The outer page margin. -->
  10. <xsl:param name="page.margin.outer" select="'0.375in'"/>
  11. <!-- The bottom margin of the page. -->
  12. <xsl:param name="page.margin.bottom" select="'0.375in'"/>
  13. <!-- The top margin of the page. -->
  14. <xsl:param name="page.margin.top" select="'0.375in'"/>
  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. <!-- Rule under headers? 1 =yes, 0 = no -->
  28. <xsl:param name="header.rule" select="0"/>
  29. <!-- Rule over footers? 1 =yes, 0 = no -->
  30. <xsl:param name="footer.rule" select="0"></xsl:param>
  31. <!-- Control depth of sections shown in running headers or footers.
  32. Be sure that no uneeded fo:marker are generated. -->
  33. <xsl:param name="marker.section.level" select="-1"></xsl:param>
  34. <!-- Force sect1 onto a new page -->
  35. <xsl:attribute-set name="section.level1.properties">
  36. <xsl:attribute name="break-before">
  37. <xsl:choose>
  38. <!--<xsl:when test="not(. = //*/sect1[1])">
  39. <xsl:text>page</xsl:text>
  40. </xsl:when>-->
  41. <xsl:when test="preceding-sibling::sect1[position()=1]/sect2/@role='package'
  42. or self::sect1/sect2/@role='package'">page</xsl:when>
  43. <xsl:otherwise>
  44. <xsl:text>auto</xsl:text>
  45. </xsl:otherwise>
  46. </xsl:choose>
  47. </xsl:attribute>
  48. </xsl:attribute-set>
  49. <!-- book title:
  50. Centered the title and removed unused code. -->
  51. <!-- The original template is in {docbook-xsl}/fo/titlepage.templates.xsl -->
  52. <xsl:template name="book.titlepage">
  53. <fo:block margin-top="3in">
  54. <fo:block>
  55. <xsl:call-template name="book.titlepage.before.recto"/>
  56. <xsl:call-template name="book.titlepage.recto"/>
  57. </fo:block>
  58. <fo:block>
  59. <xsl:call-template name="book.titlepage.before.verso"/>
  60. <xsl:call-template name="book.titlepage.verso"/>
  61. </fo:block>
  62. <xsl:call-template name="book.titlepage.separator"/>
  63. </fo:block>
  64. </xsl:template>
  65. <!-- book title:
  66. Drop a blank page after book title. -->
  67. <!-- The original template is in {docbook-xsl}/fo/titlepage.templates.xsl -->
  68. <xsl:template name="book.titlepage.separator"/>
  69. <!-- part title:
  70. Centered the title and removed unused code. -->
  71. <!-- The original template is in {docbook-xsl}/fo/titlepage.templates.xsl -->
  72. <xsl:template name="part.titlepage">
  73. <fo:block>
  74. <fo:block margin-top="3.5in">
  75. <xsl:call-template name="part.titlepage.before.recto"/>
  76. <xsl:call-template name="part.titlepage.recto"/>
  77. </fo:block>
  78. <fo:block>
  79. <xsl:call-template name="part.titlepage.before.verso"/>
  80. <xsl:call-template name="part.titlepage.verso"/>
  81. </fo:block>
  82. <xsl:call-template name="part.titlepage.separator"/>
  83. </fo:block>
  84. </xsl:template>
  85. <!-- chapter title:
  86. Small font size and left alignament. -->
  87. <!-- The original template is in {docbook-xsl}/fo/titlepage.templates.xsl -->
  88. <xsl:template match="title" mode="chapter.titlepage.recto.auto.mode">
  89. <fo:block xsl:use-attribute-sets="chapter.titlepage.recto.style"
  90. font-size="21pt" font-weight="bold" text-align="left">
  91. <xsl:call-template name="component.title">
  92. <xsl:with-param name="node" select="ancestor-or-self::chapter[1]"/>
  93. </xsl:call-template>
  94. </fo:block>
  95. </xsl:template>
  96. <!-- sect2 title:
  97. Skip sect2.titlepage run when title is empty.
  98. Removed unused code. -->
  99. <!-- The original template is in {docbook-xsl}/fo/sections.xsl -->
  100. <xsl:template match="sect2">
  101. <xsl:variable name="id">
  102. <xsl:call-template name="object.id"/>
  103. </xsl:variable>
  104. <fo:block xsl:use-attribute-sets="section.level2.properties">
  105. <xsl:attribute name="id">
  106. <xsl:value-of select="$id"/>
  107. </xsl:attribute>
  108. <xsl:if test="not(string-length(title)=0)">
  109. <xsl:call-template name="sect2.titlepage"/>
  110. </xsl:if>
  111. <xsl:apply-templates/>
  112. </fo:block>
  113. </xsl:template>
  114. <!-- header.table:
  115. Re-made template to not generate a fo:table in the header,
  116. allowing a more simple header.content custonization. -->
  117. <!-- The original template is in {docbook-xsl}/fo/pagesetup.xsl -->
  118. <xsl:template name="header.table">
  119. <xsl:param name="sequence" select="''"/>
  120. <xsl:param name="gentext-key" select="''"/>
  121. <xsl:choose>
  122. <xsl:when test="$gentext-key = 'book' or $sequence = 'blank'"/>
  123. <xsl:otherwise>
  124. <xsl:call-template name="header.content">
  125. <xsl:with-param name="sequence" select="$sequence"/>
  126. </xsl:call-template>
  127. </xsl:otherwise>
  128. </xsl:choose>
  129. </xsl:template>
  130. <!-- header.content
  131. Re-made template to show the book title and version on all pages. -->
  132. <!-- The original template is in {docbook-xsl}/fo/pagesetup.xsl -->
  133. <xsl:template name="header.content">
  134. <xsl:param name="sequence" select="''"/>
  135. <fo:block>
  136. <xsl:attribute name="text-align">
  137. <xsl:choose>
  138. <xsl:when test="$sequence = 'first' or $sequence = 'odd'">right</xsl:when>
  139. <xsl:otherwise>left</xsl:otherwise>
  140. </xsl:choose>
  141. </xsl:attribute>
  142. <xsl:value-of select="/book/bookinfo/title"/>
  143. <xsl:text> - </xsl:text>
  144. <xsl:value-of select="/book/bookinfo/subtitle"/>
  145. </fo:block>
  146. </xsl:template>
  147. </xsl:stylesheet>