lfs-mixed.xsl 11 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 contains misc params, attribute sets and templates
  6. for output formating.
  7. This file is for that templates that don't fit in other files. -->
  8. <!-- What space do you want between normal paragraphs. -->
  9. <xsl:attribute-set name="normal.para.spacing">
  10. <xsl:attribute name="space-before.optimum">0.6em</xsl:attribute>
  11. <xsl:attribute name="space-before.minimum">0.4em</xsl:attribute>
  12. <xsl:attribute name="space-before.maximum">0.8em</xsl:attribute>
  13. <xsl:attribute name="orphans">3</xsl:attribute>
  14. <xsl:attribute name="widows">3</xsl:attribute>
  15. </xsl:attribute-set>
  16. <!-- Properties associated with verbatim text. -->
  17. <xsl:attribute-set name="verbatim.properties">
  18. <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
  19. <xsl:attribute name="keep-with-previous.within-column">always</xsl:attribute>
  20. <xsl:attribute name="space-before.optimum">0.6em</xsl:attribute>
  21. <xsl:attribute name="space-before.minimum">0.4em</xsl:attribute>
  22. <xsl:attribute name="space-before.maximum">0.8em</xsl:attribute>
  23. <xsl:attribute name="space-after.optimum">0.6em</xsl:attribute>
  24. <xsl:attribute name="space-after.minimum">0.4em</xsl:attribute>
  25. <xsl:attribute name="space-after.maximum">0.8em</xsl:attribute>
  26. <xsl:attribute name="hyphenate">false</xsl:attribute>
  27. <xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
  28. <xsl:attribute name="white-space-collapse">false</xsl:attribute>
  29. <xsl:attribute name="white-space-treatment">preserve</xsl:attribute>
  30. <xsl:attribute name="linefeed-treatment">preserve</xsl:attribute>
  31. <xsl:attribute name="text-align">start</xsl:attribute>
  32. </xsl:attribute-set>
  33. <!-- Should verbatim environments be shaded? 1 =yes, 0 = no -->
  34. <xsl:param name="shade.verbatim" select="1"/>
  35. <!-- Properties that specify the style of shaded verbatim listings -->
  36. <xsl:attribute-set name="shade.verbatim.style">
  37. <xsl:attribute name="background-color">#E9E9E9</xsl:attribute>
  38. <xsl:attribute name="border-style">solid</xsl:attribute>
  39. <xsl:attribute name="border-width">1pt</xsl:attribute>
  40. <xsl:attribute name="border-color">#050505</xsl:attribute>
  41. <xsl:attribute name="padding-start">5pt</xsl:attribute>
  42. <xsl:attribute name="padding-top">2pt</xsl:attribute>
  43. <xsl:attribute name="padding-bottom">2pt</xsl:attribute>
  44. </xsl:attribute-set>
  45. <!-- para:
  46. Skip empty "Home page" in packages.xml.
  47. Allow forced line breaks inside paragraphs emulating literallayout.
  48. Removed vertical space in variablelist. -->
  49. <!-- The original template is in {docbook-xsl}/fo/block.xsl -->
  50. <xsl:template match="para">
  51. <xsl:choose>
  52. <xsl:when test="child::ulink[@url=' ']"/>
  53. <xsl:when test="./@remap='verbatim'">
  54. <fo:block xsl:use-attribute-sets="verbatim.properties">
  55. <xsl:call-template name="anchor"/>
  56. <xsl:apply-templates/>
  57. </fo:block>
  58. </xsl:when>
  59. <xsl:when test="ancestor::variablelist">
  60. <fo:block>
  61. <xsl:attribute name="space-before.optimum">0.1em</xsl:attribute>
  62. <xsl:attribute name="space-before.minimum">0em</xsl:attribute>
  63. <xsl:attribute name="space-before.maximum">0.2em</xsl:attribute>
  64. <xsl:call-template name="anchor"/>
  65. <xsl:apply-templates/>
  66. </fo:block>
  67. </xsl:when>
  68. <xsl:otherwise>
  69. <fo:block xsl:use-attribute-sets="normal.para.spacing">
  70. <xsl:call-template name="anchor"/>
  71. <xsl:apply-templates/>
  72. </fo:block>
  73. </xsl:otherwise>
  74. </xsl:choose>
  75. </xsl:template>
  76. <!-- literal:
  77. Be sure that literal will use allways normal font weight. -->
  78. <!-- The original template is in {docbook-xsl}/fo/inline.xsl -->
  79. <xsl:template match="literal">
  80. <fo:inline font-weight="normal">
  81. <xsl:call-template name="inline.monoseq"/>
  82. </fo:inline>
  83. </xsl:template>
  84. <!-- Show external URLs in italic font -->
  85. <xsl:attribute-set name="xref.properties">
  86. <xsl:attribute name="font-style">
  87. <xsl:choose>
  88. <xsl:when test="self::ulink">italic</xsl:when>
  89. <xsl:otherwise>inherit</xsl:otherwise>
  90. </xsl:choose>
  91. </xsl:attribute>
  92. </xsl:attribute-set>
  93. <!-- Lists -->
  94. <!-- What spacing do you want before and after lists? -->
  95. <xsl:attribute-set name="list.block.spacing">
  96. <xsl:attribute name="space-before.optimum">0.6em</xsl:attribute>
  97. <xsl:attribute name="space-before.minimum">0.4em</xsl:attribute>
  98. <xsl:attribute name="space-before.maximum">0.8em</xsl:attribute>
  99. <xsl:attribute name="space-after.optimum">0.6em</xsl:attribute>
  100. <xsl:attribute name="space-after.minimum">0.4em</xsl:attribute>
  101. <xsl:attribute name="space-after.maximum">0.8em</xsl:attribute>
  102. </xsl:attribute-set>
  103. <!-- What spacing do you want between list items?
  104. No space in nested itemizedlist, like in the Changelog. -->
  105. <xsl:attribute-set name="list.item.spacing">
  106. <xsl:attribute name="space-before.optimum">
  107. <xsl:choose>
  108. <xsl:when test=". = //listitem/itemizedlist/listitem">0em</xsl:when>
  109. <xsl:otherwise>0.4em</xsl:otherwise>
  110. </xsl:choose>
  111. </xsl:attribute>
  112. <xsl:attribute name="space-before.minimum">
  113. <xsl:choose>
  114. <xsl:when test=". = //listitem/itemizedlist/listitem">0em</xsl:when>
  115. <xsl:otherwise>0.2em</xsl:otherwise>
  116. </xsl:choose>
  117. </xsl:attribute>
  118. <xsl:attribute name="space-before.maximum">
  119. <xsl:choose>
  120. <xsl:when test=". = //listitem/itemizedlist/listitem">0.2em</xsl:when>
  121. <xsl:otherwise>0.6em</xsl:otherwise>
  122. </xsl:choose>
  123. </xsl:attribute>
  124. </xsl:attribute-set>
  125. <!-- Properties that apply to each list-block generated by itemizedlist. -->
  126. <xsl:attribute-set name="itemizedlist.properties"
  127. use-attribute-sets="list.block.properties">
  128. <xsl:attribute name="text-align">left</xsl:attribute>
  129. </xsl:attribute-set>
  130. <!-- Format variablelists lists as blocks? 1 = yes, 0 = no
  131. Default variablelist format. We override it when necesary
  132. using the list-presentation processing instruction. -->
  133. <xsl:param name="variablelist.as.blocks" select="1"/>
  134. <!-- Specifies the longest term in variablelists.
  135. Used when list-presentation = list -->
  136. <xsl:param name="variablelist.max.termlength">32</xsl:param>
  137. <!-- varlistentry mode block:
  138. Addibg a bullet, left alignament, and @kepp-*.* attributes
  139. for packages and paches list. -->
  140. <!-- The original template is in {docbook-xsl}/fo/list.xsl -->
  141. <xsl:template match="varlistentry" mode="vl.as.blocks">
  142. <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
  143. <xsl:choose>
  144. <xsl:when test="ancestor::variablelist/@role = 'materials'">
  145. <fo:block id="{$id}" xsl:use-attribute-sets="list.item.spacing"
  146. keep-together.within-column="always"
  147. keep-with-next.within-column="always" text-align="left">
  148. <xsl:text>&#x2022; </xsl:text>
  149. <xsl:apply-templates select="term"/>
  150. </fo:block>
  151. <fo:block margin-left="1.4pc" text-align="left"
  152. keep-together.within-column="always"
  153. keep-with-previous.within-column="always">
  154. <xsl:apply-templates select="listitem"/>
  155. </fo:block>
  156. </xsl:when>
  157. <xsl:otherwise>
  158. <fo:block id="{$id}" xsl:use-attribute-sets="list.item.spacing"
  159. keep-together.within-column="always"
  160. keep-with-next.within-column="always">
  161. <xsl:apply-templates select="term"/>
  162. </fo:block>
  163. <fo:block margin-left="0.25in">
  164. <xsl:apply-templates select="listitem"/>
  165. </fo:block>
  166. </xsl:otherwise>
  167. </xsl:choose>
  168. </xsl:template>
  169. <!-- segmentedlist:
  170. Making it an actual FO list to can indent items.
  171. Adjust vertical space. -->
  172. <!-- The original template is in {docbook-xsl}/fo/list.xsl -->
  173. <xsl:template match="segmentedlist">
  174. <fo:list-block provisional-distance-between-starts="12em"
  175. provisional-label-separation="1em"
  176. keep-together.within-column="always">
  177. <xsl:choose>
  178. <xsl:when test="ancestor::appendix[@id='appendixc']">
  179. <xsl:attribute name="space-before.optimum">0.2em</xsl:attribute>
  180. <xsl:attribute name="space-before.minimum">0em</xsl:attribute>
  181. <xsl:attribute name="space-before.maximum">0.4em</xsl:attribute>
  182. <xsl:attribute name="space-after.optimum">0.2em</xsl:attribute>
  183. <xsl:attribute name="space-after.minimum">0em</xsl:attribute>
  184. <xsl:attribute name="space-after.maximum">0.4em</xsl:attribute>
  185. <xsl:attribute name="keep-with-previous.within-column">always</xsl:attribute>
  186. </xsl:when>
  187. <xsl:attribute name="space-before.optimum">0.6em</xsl:attribute>
  188. <xsl:attribute name="space-before.minimum">0.4em</xsl:attribute>
  189. <xsl:attribute name="space-before.maximum">0.8em</xsl:attribute>
  190. <xsl:attribute name="space-after.optimum">0.6em</xsl:attribute>
  191. <xsl:attribute name="space-after.minimum">0.4em</xsl:attribute>
  192. <xsl:attribute name="space-after.maximum">0.8em</xsl:attribute>
  193. <xsl:otherwise>
  194. </xsl:otherwise>
  195. </xsl:choose>
  196. <xsl:apply-templates select="seglistitem/seg"/>
  197. </fo:list-block>
  198. </xsl:template>
  199. <!-- seg:
  200. Self-made template based on the original seg template
  201. found in {docbook-xsl}/fo/list.xsl
  202. Making segmentedlist an actual FO list to can indent items. -->
  203. <xsl:template match="seglistitem/seg">
  204. <xsl:variable name="segnum" select="count(preceding-sibling::seg)+1"/>
  205. <xsl:variable name="seglist" select="ancestor::segmentedlist"/>
  206. <xsl:variable name="segtitles" select="$seglist/segtitle"/>
  207. <fo:list-item xsl:use-attribute-sets="compact.list.item.spacing">
  208. <fo:list-item-label end-indent="label-end()" text-align="start">
  209. <fo:block>
  210. <fo:inline font-weight="bold">
  211. <xsl:apply-templates select="$segtitles[$segnum=position()]"
  212. mode="segtitle-in-seg"/>
  213. <xsl:text>:</xsl:text>
  214. </fo:inline>
  215. </fo:block>
  216. </fo:list-item-label>
  217. <fo:list-item-body start-indent="body-start()">
  218. <fo:block>
  219. <xsl:apply-templates/>
  220. </fo:block>
  221. </fo:list-item-body>
  222. </fo:list-item>
  223. </xsl:template>
  224. </xsl:stylesheet>