lfs-mixed.xsl 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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">0.5pt</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. <!-- inline.monoseq:
  85. Added hyphenate-url support to classname, exceptionname, interfacename,
  86. methodname, computeroutput, constant, envar, filename, function, code,
  87. literal, option, promt, systemitem, varname, sgmltag, tag, and uri -->
  88. <!-- The original template is in {docbook-xsl}/fo/inline.xsl -->
  89. <xsl:template name="inline.monoseq">
  90. <xsl:param name="content">
  91. <xsl:call-template name="simple.xlink">
  92. <xsl:with-param name="content">
  93. <xsl:call-template name="hyphenate-url">
  94. <xsl:with-param name="url">
  95. <xsl:apply-templates/>
  96. </xsl:with-param>
  97. </xsl:call-template>
  98. </xsl:with-param>
  99. </xsl:call-template>
  100. </xsl:param>
  101. <fo:inline xsl:use-attribute-sets="monospace.properties">
  102. <xsl:if test="@dir">
  103. <xsl:attribute name="direction">
  104. <xsl:choose>
  105. <xsl:when test="@dir = 'ltr' or @dir = 'lro'">ltr</xsl:when>
  106. <xsl:otherwise>rtl</xsl:otherwise>
  107. </xsl:choose>
  108. </xsl:attribute>
  109. </xsl:if>
  110. <xsl:copy-of select="$content"/>
  111. </fo:inline>
  112. </xsl:template>
  113. <!-- inline.italicmonoseq:
  114. Added hyphenate-url support to parameter, replaceable, structfield,
  115. function/parameter, and function/replaceable -->
  116. <!-- The original template is in {docbook-xsl}/fo/inline.xsl -->
  117. <xsl:template name="inline.italicmonoseq">
  118. <xsl:param name="content">
  119. <xsl:call-template name="simple.xlink">
  120. <xsl:with-param name="content">
  121. <xsl:call-template name="hyphenate-url">
  122. <xsl:with-param name="url">
  123. <xsl:apply-templates/>
  124. </xsl:with-param>
  125. </xsl:call-template>
  126. </xsl:with-param>
  127. </xsl:call-template>
  128. </xsl:param>
  129. <fo:inline font-style="italic" xsl:use-attribute-sets="monospace.properties">
  130. <xsl:call-template name="anchor"/>
  131. <xsl:if test="@dir">
  132. <xsl:attribute name="direction">
  133. <xsl:choose>
  134. <xsl:when test="@dir = 'ltr' or @dir = 'lro'">ltr</xsl:when>
  135. <xsl:otherwise>rtl</xsl:otherwise>
  136. </xsl:choose>
  137. </xsl:attribute>
  138. </xsl:if>
  139. <xsl:copy-of select="$content"/>
  140. </fo:inline>
  141. </xsl:template>
  142. <!-- Show external URLs in italic font -->
  143. <xsl:attribute-set name="xref.properties">
  144. <xsl:attribute name="font-style">
  145. <xsl:choose>
  146. <xsl:when test="self::ulink">italic</xsl:when>
  147. <xsl:otherwise>inherit</xsl:otherwise>
  148. </xsl:choose>
  149. </xsl:attribute>
  150. </xsl:attribute-set>
  151. <!-- Lists -->
  152. <!-- What spacing do you want before and after lists? -->
  153. <xsl:attribute-set name="list.block.spacing">
  154. <xsl:attribute name="space-before.optimum">0.6em</xsl:attribute>
  155. <xsl:attribute name="space-before.minimum">0.4em</xsl:attribute>
  156. <xsl:attribute name="space-before.maximum">0.8em</xsl:attribute>
  157. <xsl:attribute name="space-after.optimum">0.6em</xsl:attribute>
  158. <xsl:attribute name="space-after.minimum">0.4em</xsl:attribute>
  159. <xsl:attribute name="space-after.maximum">0.8em</xsl:attribute>
  160. </xsl:attribute-set>
  161. <!-- What spacing do you want between list items?
  162. No space in nested itemizedlist, like in the Changelog. -->
  163. <xsl:attribute-set name="list.item.spacing">
  164. <xsl:attribute name="space-before.optimum">
  165. <xsl:choose>
  166. <xsl:when test=". = //listitem/itemizedlist/listitem">0em</xsl:when>
  167. <xsl:otherwise>0.4em</xsl:otherwise>
  168. </xsl:choose>
  169. </xsl:attribute>
  170. <xsl:attribute name="space-before.minimum">
  171. <xsl:choose>
  172. <xsl:when test=". = //listitem/itemizedlist/listitem">0em</xsl:when>
  173. <xsl:otherwise>0.2em</xsl:otherwise>
  174. </xsl:choose>
  175. </xsl:attribute>
  176. <xsl:attribute name="space-before.maximum">
  177. <xsl:choose>
  178. <xsl:when test=". = //listitem/itemizedlist/listitem">0.2em</xsl:when>
  179. <xsl:otherwise>0.6em</xsl:otherwise>
  180. </xsl:choose>
  181. </xsl:attribute>
  182. </xsl:attribute-set>
  183. <!-- Properties that apply to each list-block generated by itemizedlist. -->
  184. <xsl:attribute-set name="itemizedlist.properties"
  185. use-attribute-sets="list.block.properties">
  186. <xsl:attribute name="text-align">left</xsl:attribute>
  187. </xsl:attribute-set>
  188. <!-- Format variablelists lists as blocks? 1 = yes, 0 = no
  189. Default variablelist format. We override it when necesary
  190. using the list-presentation processing instruction. -->
  191. <xsl:param name="variablelist.as.blocks" select="1"/>
  192. <!-- Specifies the longest term in variablelists.
  193. Used when list-presentation = list -->
  194. <xsl:param name="variablelist.max.termlength">32</xsl:param>
  195. <!-- varlistentry mode block:
  196. Addibg a bullet, left alignament, and @kepp-*.* attributes
  197. for packages and paches list. -->
  198. <!-- The original template is in {docbook-xsl}/fo/list.xsl -->
  199. <xsl:template match="varlistentry" mode="vl.as.blocks">
  200. <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
  201. <xsl:choose>
  202. <xsl:when test="ancestor::variablelist/@role = 'materials'">
  203. <fo:block id="{$id}" xsl:use-attribute-sets="list.item.spacing"
  204. keep-together.within-column="always"
  205. keep-with-next.within-column="always" text-align="left">
  206. <xsl:text>&#x2022; </xsl:text>
  207. <xsl:apply-templates select="term"/>
  208. </fo:block>
  209. <fo:block margin-left="1.4pc" text-align="left"
  210. keep-together.within-column="always"
  211. keep-with-previous.within-column="always">
  212. <xsl:apply-templates select="listitem"/>
  213. </fo:block>
  214. </xsl:when>
  215. <xsl:otherwise>
  216. <fo:block id="{$id}" xsl:use-attribute-sets="list.item.spacing"
  217. keep-together.within-column="always"
  218. keep-with-next.within-column="always">
  219. <xsl:apply-templates select="term"/>
  220. </fo:block>
  221. <fo:block margin-left="0.25in">
  222. <xsl:apply-templates select="listitem"/>
  223. </fo:block>
  224. </xsl:otherwise>
  225. </xsl:choose>
  226. </xsl:template>
  227. <!-- segmentedlist:
  228. Making it an actual FO list to can indent items.
  229. Adjust vertical space. -->
  230. <!-- The original template is in {docbook-xsl}/fo/list.xsl -->
  231. <xsl:template match="segmentedlist">
  232. <fo:list-block provisional-distance-between-starts="12em"
  233. provisional-label-separation="1em"
  234. keep-together.within-column="always">
  235. <xsl:choose>
  236. <xsl:when test="ancestor::appendix[@id='appendixc']">
  237. <xsl:attribute name="space-before.optimum">0.2em</xsl:attribute>
  238. <xsl:attribute name="space-before.minimum">0em</xsl:attribute>
  239. <xsl:attribute name="space-before.maximum">0.4em</xsl:attribute>
  240. <xsl:attribute name="space-after.optimum">0.2em</xsl:attribute>
  241. <xsl:attribute name="space-after.minimum">0em</xsl:attribute>
  242. <xsl:attribute name="space-after.maximum">0.4em</xsl:attribute>
  243. <xsl:attribute name="keep-with-previous.within-column">always</xsl:attribute>
  244. </xsl:when>
  245. <xsl:attribute name="space-before.optimum">0.6em</xsl:attribute>
  246. <xsl:attribute name="space-before.minimum">0.4em</xsl:attribute>
  247. <xsl:attribute name="space-before.maximum">0.8em</xsl:attribute>
  248. <xsl:attribute name="space-after.optimum">0.6em</xsl:attribute>
  249. <xsl:attribute name="space-after.minimum">0.4em</xsl:attribute>
  250. <xsl:attribute name="space-after.maximum">0.8em</xsl:attribute>
  251. <xsl:otherwise>
  252. </xsl:otherwise>
  253. </xsl:choose>
  254. <xsl:apply-templates select="seglistitem/seg"/>
  255. </fo:list-block>
  256. </xsl:template>
  257. <!-- seg:
  258. Self-made template based on the original seg template
  259. found in {docbook-xsl}/fo/list.xsl
  260. Making segmentedlist an actual FO list to can indent items. -->
  261. <xsl:template match="seglistitem/seg">
  262. <xsl:variable name="segnum" select="count(preceding-sibling::seg)+1"/>
  263. <xsl:variable name="seglist" select="ancestor::segmentedlist"/>
  264. <xsl:variable name="segtitles" select="$seglist/segtitle"/>
  265. <fo:list-item xsl:use-attribute-sets="compact.list.item.spacing">
  266. <fo:list-item-label end-indent="label-end()" text-align="start">
  267. <fo:block>
  268. <fo:inline font-weight="bold">
  269. <xsl:apply-templates select="$segtitles[$segnum=position()]"
  270. mode="segtitle-in-seg"/>
  271. <xsl:text>:</xsl:text>
  272. </fo:inline>
  273. </fo:block>
  274. </fo:list-item-label>
  275. <fo:list-item-body start-indent="body-start()">
  276. <fo:block>
  277. <xsl:apply-templates/>
  278. </fo:block>
  279. </fo:list-item-body>
  280. </fo:list-item>
  281. </xsl:template>
  282. </xsl:stylesheet>