lfs-pagesetup.xsl 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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. <!-- Force section1's onto a new page -->
  6. <xsl:attribute-set name="section.level1.properties">
  7. <xsl:attribute name="break-after">
  8. <xsl:choose>
  9. <xsl:when test="not(position()=last())">
  10. <xsl:text>page</xsl:text>
  11. </xsl:when>
  12. <xsl:otherwise>
  13. <xsl:text>auto</xsl:text>
  14. </xsl:otherwise>
  15. </xsl:choose>
  16. </xsl:attribute>
  17. </xsl:attribute-set>
  18. <!-- Skip numeraration for sections with empty title -->
  19. <xsl:template match="sect2|sect3|sect4|sect5" mode="label.markup">
  20. <xsl:if test="string-length(title) > 0">
  21. <!-- label the parent -->
  22. <xsl:variable name="parent.label">
  23. <xsl:apply-templates select=".." mode="label.markup"/>
  24. </xsl:variable>
  25. <xsl:if test="$parent.label != ''">
  26. <xsl:apply-templates select=".." mode="label.markup"/>
  27. <xsl:apply-templates select=".." mode="intralabel.punctuation"/>
  28. </xsl:if>
  29. <xsl:choose>
  30. <xsl:when test="@label">
  31. <xsl:value-of select="@label"/>
  32. </xsl:when>
  33. <xsl:when test="$section.autolabel != 0">
  34. <xsl:choose>
  35. <xsl:when test="local-name(.) = 'sect2'">
  36. <xsl:choose>
  37. <!-- If the first sect2 isn't numbered, renumber the remainig sections -->
  38. <xsl:when test="string-length(../sect2[1]/title) = 0">
  39. <xsl:variable name="totalsect2">
  40. <xsl:number count="sect2"/>
  41. </xsl:variable>
  42. <xsl:number value="$totalsect2 - 1"/>
  43. </xsl:when>
  44. <xsl:otherwise>
  45. <xsl:number count="sect2"/>
  46. </xsl:otherwise>
  47. </xsl:choose>
  48. </xsl:when>
  49. <xsl:when test="local-name(.) = 'sect3'">
  50. <xsl:number count="sect3"/>
  51. </xsl:when>
  52. <xsl:when test="local-name(.) = 'sect4'">
  53. <xsl:number count="sect4"/>
  54. </xsl:when>
  55. <xsl:when test="local-name(.) = 'sect5'">
  56. <xsl:number count="sect5"/>
  57. </xsl:when>
  58. <xsl:otherwise>
  59. <xsl:message>label.markup: this can't happen!</xsl:message>
  60. </xsl:otherwise>
  61. </xsl:choose>
  62. </xsl:when>
  63. </xsl:choose>
  64. </xsl:if>
  65. </xsl:template>
  66. <!-- Drop the trailing punctuation if title is empty -->
  67. <xsl:template match="section|sect1|sect2|sect3|sect4|sect5|simplesect
  68. |bridgehead"
  69. mode="object.title.template">
  70. <xsl:choose>
  71. <xsl:when test="$section.autolabel != 0">
  72. <xsl:if test="string-length(title) > 0">
  73. <xsl:call-template name="gentext.template">
  74. <xsl:with-param name="context" select="'title-numbered'"/>
  75. <xsl:with-param name="name">
  76. <xsl:call-template name="xpath.location"/>
  77. </xsl:with-param>
  78. </xsl:call-template>
  79. </xsl:if>
  80. </xsl:when>
  81. <xsl:otherwise>
  82. <xsl:call-template name="gentext.template">
  83. <xsl:with-param name="context" select="'title-unnumbered'"/>
  84. <xsl:with-param name="name">
  85. <xsl:call-template name="xpath.location"/>
  86. </xsl:with-param>
  87. </xsl:call-template>
  88. </xsl:otherwise>
  89. </xsl:choose>
  90. </xsl:template>
  91. <!-- Header -->
  92. <xsl:template name="header.content">
  93. <xsl:param name="sequence" select="''"/>
  94. <fo:block>
  95. <xsl:attribute name="text-align">
  96. <xsl:choose>
  97. <xsl:when test="$sequence = 'first' or $sequence = 'odd'">right</xsl:when>
  98. <xsl:otherwise>left</xsl:otherwise>
  99. </xsl:choose>
  100. </xsl:attribute>
  101. <xsl:value-of select="/book/bookinfo/title"/>
  102. <xsl:text> - </xsl:text>
  103. <xsl:value-of select="/book/bookinfo/subtitle"/>
  104. </fo:block>
  105. </xsl:template>
  106. <xsl:template name="header.table">
  107. <xsl:param name="sequence" select="''"/>
  108. <xsl:param name="gentext-key" select="''"/>
  109. <xsl:choose>
  110. <xsl:when test="$gentext-key = 'book' or $sequence = 'blank'"/>
  111. <xsl:otherwise>
  112. <xsl:call-template name="header.content">
  113. <xsl:with-param name="sequence" select="$sequence"/>
  114. </xsl:call-template>
  115. </xsl:otherwise>
  116. </xsl:choose>
  117. </xsl:template>
  118. <!-- Centered titles for book and part -->
  119. <xsl:template name="book.titlepage">
  120. <fo:block space-before="2in">
  121. <fo:block>
  122. <xsl:call-template name="book.titlepage.before.recto"/>
  123. <xsl:call-template name="book.titlepage.recto"/>
  124. </fo:block>
  125. <fo:block>
  126. <xsl:call-template name="book.titlepage.before.verso"/>
  127. <xsl:call-template name="book.titlepage.verso"/>
  128. </fo:block>
  129. <xsl:call-template name="book.titlepage.separator"/>
  130. </fo:block>
  131. </xsl:template>
  132. <xsl:template name="part.titlepage">
  133. <fo:block xmlns:fo="http://www.w3.org/1999/XSL/Format">
  134. <fo:block space-before="2.5in">
  135. <xsl:call-template name="part.titlepage.before.recto"/>
  136. <xsl:call-template name="part.titlepage.recto"/>
  137. </fo:block>
  138. <fo:block>
  139. <xsl:call-template name="part.titlepage.before.verso"/>
  140. <xsl:call-template name="part.titlepage.verso"/>
  141. </fo:block>
  142. <xsl:call-template name="part.titlepage.separator"/>
  143. </fo:block>
  144. </xsl:template>
  145. <!-- Margins -->
  146. <xsl:param name="page.margin.inner">0.5in</xsl:param>
  147. <xsl:param name="page.margin.outer">0.375in</xsl:param>
  148. <xsl:param name="title.margin.left">-1pc</xsl:param>
  149. <xsl:attribute-set name="normal.para.spacing">
  150. <xsl:attribute name="space-before.optimum">0.8em</xsl:attribute>
  151. <xsl:attribute name="space-before.minimum">0.6em</xsl:attribute>
  152. <xsl:attribute name="space-before.maximum">1em</xsl:attribute>
  153. </xsl:attribute-set>
  154. <xsl:attribute-set name="list.block.spacing">
  155. <xsl:attribute name="space-before.optimum">0.8em</xsl:attribute>
  156. <xsl:attribute name="space-before.minimum">0.6em</xsl:attribute>
  157. <xsl:attribute name="space-before.maximum">1em</xsl:attribute>
  158. <xsl:attribute name="space-after.optimum">0.8em</xsl:attribute>
  159. <xsl:attribute name="space-after.minimum">0.6em</xsl:attribute>
  160. <xsl:attribute name="space-after.maximum">1em</xsl:attribute>
  161. </xsl:attribute-set>
  162. <xsl:attribute-set name="list.item.spacing">
  163. <xsl:attribute name="space-before.optimum">0.6em</xsl:attribute>
  164. <xsl:attribute name="space-before.minimum">0.4em</xsl:attribute>
  165. <xsl:attribute name="space-before.maximum">0.8em</xsl:attribute>
  166. </xsl:attribute-set>
  167. <xsl:attribute-set name="verbatim.properties">
  168. <xsl:attribute name="space-before.minimum">0.6em</xsl:attribute>
  169. <xsl:attribute name="space-before.optimum">0.8em</xsl:attribute>
  170. <xsl:attribute name="space-before.maximum">1em</xsl:attribute>
  171. <xsl:attribute name="space-after.minimum">0.6em</xsl:attribute>
  172. <xsl:attribute name="space-after.optimum">0.8em</xsl:attribute>
  173. <xsl:attribute name="space-after.maximum">1em</xsl:attribute>
  174. </xsl:attribute-set>
  175. <!-- Others-->
  176. <xsl:param name="header.rule" select="0"></xsl:param>
  177. <xsl:param name="footer.rule" select="0"></xsl:param>
  178. <xsl:param name="marker.section.level" select="-1"></xsl:param>
  179. <!-- Dropping a blank page -->
  180. <xsl:template name="book.titlepage.separator"/>
  181. <!-- How render a variablelist -->
  182. <xsl:param name="variablelist.as.blocks" select="1"/>
  183. <!-- Adding space before segmentedlist -->
  184. <xsl:template match="segmentedlist">
  185. <xsl:variable name="presentation">
  186. <xsl:call-template name="pi-attribute">
  187. <xsl:with-param name="pis"
  188. select="processing-instruction('dbfo')"/>
  189. <xsl:with-param name="attribute" select="'list-presentation'"/>
  190. </xsl:call-template>
  191. </xsl:variable>
  192. <xsl:choose>
  193. <xsl:when test="$presentation = 'table'">
  194. <xsl:apply-templates select="." mode="seglist-table"/>
  195. </xsl:when>
  196. <xsl:when test="$presentation = 'list'">
  197. <fo:block space-before.minimum="0.4em" space-before.optimum="0.6em"
  198. space-before.maximum="0.8em">
  199. <xsl:apply-templates/>
  200. </fo:block>
  201. </xsl:when>
  202. <xsl:when test="$segmentedlist.as.table != 0">
  203. <xsl:apply-templates select="." mode="seglist-table"/>
  204. </xsl:when>
  205. <xsl:otherwise>
  206. <fo:block space-before.minimum="0.4em" space-before.optimum="0.6em"
  207. space-before.maximum="0.8em">
  208. <xsl:apply-templates/>
  209. </fo:block>
  210. </xsl:otherwise>
  211. </xsl:choose>
  212. </xsl:template>
  213. </xsl:stylesheet>