lfs-mixed.xsl 13 KB

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