lfs-mixed.xsl 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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 vaiablelist. -->
  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. <xsl:attribute-set name="list.item.spacing">
  106. <xsl:attribute name="space-before.optimum">0.4em</xsl:attribute>
  107. <xsl:attribute name="space-before.minimum">0.2em</xsl:attribute>
  108. <xsl:attribute name="space-before.maximum">0.6em</xsl:attribute>
  109. </xsl:attribute-set>
  110. <!-- Properties that apply to each list-block generated by itemizedlist. -->
  111. <xsl:attribute-set name="itemizedlist.properties"
  112. use-attribute-sets="list.block.properties">
  113. <xsl:attribute name="text-align">left</xsl:attribute>
  114. </xsl:attribute-set>
  115. <!-- Format variablelists lists as blocks? 1 = yes, 0 = no
  116. Default variablelist format. We override it when necesary
  117. using the list-presentation processing instruction. -->
  118. <xsl:param name="variablelist.as.blocks" select="1"/>
  119. <!-- Specifies the longest term in variablelists.
  120. Used when list-presentation = list -->
  121. <xsl:param name="variablelist.max.termlength">32</xsl:param>
  122. <!-- varlistentry mode block:
  123. Addibg a bullet, left alignament, and @kepp-*.* attributes
  124. for packages and paches list. -->
  125. <!-- The original template is in {docbook-xsl}/fo/list.xsl -->
  126. <xsl:template match="varlistentry" mode="vl.as.blocks">
  127. <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
  128. <xsl:choose>
  129. <xsl:when test="ancestor::variablelist/@role = 'materials'">
  130. <fo:block id="{$id}" xsl:use-attribute-sets="list.item.spacing"
  131. keep-together.within-column="always"
  132. keep-with-next.within-column="always" text-align="left">
  133. <xsl:text>&#x2022; </xsl:text>
  134. <xsl:apply-templates select="term"/>
  135. </fo:block>
  136. <fo:block margin-left="1.4pc" text-align="left"
  137. keep-together.within-column="always"
  138. keep-with-previous.within-column="always">
  139. <xsl:apply-templates select="listitem"/>
  140. </fo:block>
  141. </xsl:when>
  142. <xsl:otherwise>
  143. <fo:block id="{$id}" xsl:use-attribute-sets="list.item.spacing"
  144. keep-together.within-column="always"
  145. keep-with-next.within-column="always">
  146. <xsl:apply-templates select="term"/>
  147. </fo:block>
  148. <fo:block margin-left="0.25in">
  149. <xsl:apply-templates select="listitem"/>
  150. </fo:block>
  151. </xsl:otherwise>
  152. </xsl:choose>
  153. </xsl:template>
  154. <!-- segmentedlist:
  155. Making it an actual FO list to can indent items.
  156. Adjust vertical space. -->
  157. <!-- The original template is in {docbook-xsl}/fo/list.xsl -->
  158. <xsl:template match="segmentedlist">
  159. <fo:list-block provisional-distance-between-starts="12em"
  160. provisional-label-separation="1em"
  161. keep-together.within-column="always">
  162. <xsl:choose>
  163. <xsl:when test="ancestor::appendix[@id='appendixc']">
  164. <xsl:attribute name="space-before.optimum">0.2em</xsl:attribute>
  165. <xsl:attribute name="space-before.minimum">0em</xsl:attribute>
  166. <xsl:attribute name="space-before.maximum">0.4em</xsl:attribute>
  167. <xsl:attribute name="space-after.optimum">0.2em</xsl:attribute>
  168. <xsl:attribute name="space-after.minimum">0em</xsl:attribute>
  169. <xsl:attribute name="space-after.maximum">0.4em</xsl:attribute>
  170. <xsl:attribute name="keep-with-previous.within-column">always</xsl:attribute>
  171. </xsl:when>
  172. <xsl:attribute name="space-before.optimum">0.6em</xsl:attribute>
  173. <xsl:attribute name="space-before.minimum">0.4em</xsl:attribute>
  174. <xsl:attribute name="space-before.maximum">0.8em</xsl:attribute>
  175. <xsl:attribute name="space-after.optimum">0.6em</xsl:attribute>
  176. <xsl:attribute name="space-after.minimum">0.4em</xsl:attribute>
  177. <xsl:attribute name="space-after.maximum">0.8em</xsl:attribute>
  178. <xsl:otherwise>
  179. </xsl:otherwise>
  180. </xsl:choose>
  181. <xsl:apply-templates select="seglistitem/seg"/>
  182. </fo:list-block>
  183. </xsl:template>
  184. <!-- seg:
  185. Self-made template based on the original seg template
  186. found in {docbook-xsl}/fo/list.xsl
  187. Making segmentedlist an actual FO list to can indent items. -->
  188. <xsl:template match="seglistitem/seg">
  189. <xsl:variable name="segnum" select="count(preceding-sibling::seg)+1"/>
  190. <xsl:variable name="seglist" select="ancestor::segmentedlist"/>
  191. <xsl:variable name="segtitles" select="$seglist/segtitle"/>
  192. <fo:list-item xsl:use-attribute-sets="compact.list.item.spacing">
  193. <fo:list-item-label end-indent="label-end()" text-align="start">
  194. <fo:block>
  195. <fo:inline font-weight="bold">
  196. <xsl:apply-templates select="$segtitles[$segnum=position()]"
  197. mode="segtitle-in-seg"/>
  198. <xsl:text>:</xsl:text>
  199. </fo:inline>
  200. </fo:block>
  201. </fo:list-item-label>
  202. <fo:list-item-body start-indent="body-start()">
  203. <fo:block>
  204. <xsl:apply-templates/>
  205. </fo:block>
  206. </fo:list-item-body>
  207. </fo:list-item>
  208. </xsl:template>
  209. <!-- Total packages size calculation -->
  210. <!-- returnvalue:
  211. If the tag is not empty, apply the original template.
  212. Otherwise apply the calculation template. -->
  213. <!-- The original template is in {docbook-xsl}/fo/inline.xsl -->
  214. <xsl:template match="returnvalue">
  215. <xsl:choose>
  216. <xsl:when test="count(*)&gt;0">
  217. <xsl:apply-imports/>
  218. </xsl:when>
  219. <xsl:otherwise>
  220. <xsl:call-template name="calculation">
  221. <xsl:with-param name="scope" select="../../variablelist"/>
  222. </xsl:call-template>
  223. </xsl:otherwise>
  224. </xsl:choose>
  225. </xsl:template>
  226. <xsl:template name="calculation">
  227. <xsl:param name="scope"/>
  228. <xsl:param name="total">0</xsl:param>
  229. <xsl:param name="position">1</xsl:param>
  230. <xsl:variable name="tokens" select="count($scope/varlistentry)"/>
  231. <xsl:variable name="token" select="$scope/varlistentry[$position]/term/token"/>
  232. <xsl:variable name="size" select="substring-before($token,' KB')"/>
  233. <xsl:variable name="rawsize">
  234. <xsl:choose>
  235. <xsl:when test="contains($size,',')">
  236. <xsl:value-of select="concat(substring-before($size,','),substring-after($size,','))"/>
  237. </xsl:when>
  238. <xsl:otherwise>
  239. <xsl:value-of select="$size"/>
  240. </xsl:otherwise>
  241. </xsl:choose>
  242. </xsl:variable>
  243. <xsl:choose>
  244. <xsl:when test="$position &lt;= $tokens">
  245. <xsl:call-template name="calculation">
  246. <xsl:with-param name="scope" select="$scope"/>
  247. <xsl:with-param name="position" select="$position +1"/>
  248. <xsl:with-param name="total" select="$total + $rawsize"/>
  249. </xsl:call-template>
  250. </xsl:when>
  251. <xsl:otherwise>
  252. <xsl:choose>
  253. <xsl:when test="$total &lt; '1000'">
  254. <xsl:value-of select="$total"/>
  255. <xsl:text> KB</xsl:text>
  256. </xsl:when>
  257. <xsl:when test="$total &gt; '1000' and $total &lt; '5000'">
  258. <xsl:value-of select="substring($total,1,1)"/>
  259. <xsl:text>,</xsl:text>
  260. <xsl:value-of select="substring($total,2)"/>
  261. <xsl:text> KB</xsl:text>
  262. </xsl:when>
  263. <xsl:otherwise>
  264. <xsl:value-of select="round($total div 1024)"/>
  265. <xsl:text> MB</xsl:text>
  266. </xsl:otherwise>
  267. </xsl:choose>
  268. </xsl:otherwise>
  269. </xsl:choose>
  270. </xsl:template>
  271. </xsl:stylesheet>