lfs-mixed.xsl 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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">2</xsl:attribute>
  14. <xsl:attribute name="widows">2</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 pakages and patches pages. -->
  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/@role = 'materials'">
  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. <!-- How is rendered by default a variablelist -->
  94. <xsl:param name="variablelist.as.blocks" select="1"/>
  95. <xsl:param name="variablelist.max.termlength">32</xsl:param>
  96. <!-- Adding space before segmentedlist -->
  97. <xsl:template match="segmentedlist">
  98. <!--<xsl:variable name="presentation">
  99. <xsl:call-template name="pi-attribute">
  100. <xsl:with-param name="pis"
  101. select="processing-instruction('dbfo')"/>
  102. <xsl:with-param name="attribute" select="'list-presentation'"/>
  103. </xsl:call-template>
  104. </xsl:variable>
  105. <xsl:choose>
  106. <xsl:when test="$presentation = 'table'">
  107. <xsl:apply-templates select="." mode="seglist-table"/>
  108. </xsl:when>
  109. <xsl:when test="$presentation = 'list'">
  110. <fo:block space-before.minimum="0.4em" space-before.optimum="0.6em"
  111. space-before.maximum="0.8em">
  112. <xsl:apply-templates/>
  113. </fo:block>
  114. </xsl:when>
  115. <xsl:when test="$segmentedlist.as.table != 0">
  116. <xsl:apply-templates select="." mode="seglist-table"/>
  117. </xsl:when>
  118. <xsl:otherwise>-->
  119. <fo:block space-before.minimum="0.4em" space-before.optimum="0.6em"
  120. space-before.maximum="0.8em">
  121. <xsl:apply-templates/>
  122. </fo:block>
  123. <!--</xsl:otherwise>
  124. </xsl:choose>-->
  125. </xsl:template>
  126. <!-- Left alingnament for itemizedlist -->
  127. <xsl:template match="itemizedlist">
  128. <xsl:variable name="id">
  129. <xsl:call-template name="object.id"/>
  130. </xsl:variable>
  131. <xsl:variable name="label-width">
  132. <xsl:call-template name="dbfo-attribute">
  133. <xsl:with-param name="pis"
  134. select="processing-instruction('dbfo')"/>
  135. <xsl:with-param name="attribute" select="'label-width'"/>
  136. </xsl:call-template>
  137. </xsl:variable>
  138. <xsl:if test="title">
  139. <xsl:apply-templates select="title" mode="list.title.mode"/>
  140. </xsl:if>
  141. <!-- Preserve order of PIs and comments -->
  142. <xsl:apply-templates
  143. select="*[not(self::listitem
  144. or self::title
  145. or self::titleabbrev)]
  146. |comment()[not(preceding-sibling::listitem)]
  147. |processing-instruction()[not(preceding-sibling::listitem)]"/>
  148. <fo:list-block id="{$id}" xsl:use-attribute-sets="list.block.spacing"
  149. provisional-label-separation="0.2em" text-align="left">
  150. <xsl:attribute name="provisional-distance-between-starts">
  151. <xsl:choose>
  152. <xsl:when test="$label-width != ''">
  153. <xsl:value-of select="$label-width"/>
  154. </xsl:when>
  155. <xsl:otherwise>1.5em</xsl:otherwise>
  156. </xsl:choose>
  157. </xsl:attribute>
  158. <xsl:apply-templates
  159. select="listitem
  160. |comment()[preceding-sibling::listitem]
  161. |processing-instruction()[preceding-sibling::listitem]"/>
  162. </fo:list-block>
  163. </xsl:template>
  164. <!-- Addibg a bullet, and left alignament, for packages and paches list. -->
  165. <xsl:template match="varlistentry" mode="vl.as.blocks">
  166. <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
  167. <xsl:choose>
  168. <xsl:when test="ancestor::variablelist/@role = 'materials'">
  169. <fo:block id="{$id}" xsl:use-attribute-sets="list.item.spacing"
  170. keep-together.within-column="always"
  171. keep-with-next.within-column="always" text-align="left">
  172. <xsl:text>&#x2022; </xsl:text>
  173. <xsl:apply-templates select="term"/>
  174. </fo:block>
  175. <fo:block margin-left="1.4pc" text-align="left">
  176. <xsl:apply-templates select="listitem"/>
  177. </fo:block>
  178. </xsl:when>
  179. <xsl:otherwise>
  180. <fo:block id="{$id}" xsl:use-attribute-sets="list.item.spacing"
  181. keep-together.within-column="always"
  182. keep-with-next.within-column="always">
  183. <xsl:apply-templates select="term"/>
  184. </fo:block>
  185. <fo:block margin-left="0.25in">
  186. <xsl:apply-templates select="listitem"/>
  187. </fo:block>
  188. </xsl:otherwise>
  189. </xsl:choose>
  190. </xsl:template>
  191. <!-- Total packages size calculation -->
  192. <!-- returnvalue:
  193. If the tag is not empty, apply the original template.
  194. Otherwise apply the calculation template. -->
  195. <!-- The original template is in {docbook-xsl}/fo/inline.xsl -->
  196. <xsl:template match="returnvalue">
  197. <xsl:choose>
  198. <xsl:when test="count(*)&gt;0">
  199. <xsl:apply-imports/>
  200. </xsl:when>
  201. <xsl:otherwise>
  202. <xsl:call-template name="calculation">
  203. <xsl:with-param name="scope" select="../../variablelist"/>
  204. </xsl:call-template>
  205. </xsl:otherwise>
  206. </xsl:choose>
  207. </xsl:template>
  208. <xsl:template name="calculation">
  209. <xsl:param name="scope"/>
  210. <xsl:param name="total">0</xsl:param>
  211. <xsl:param name="position">1</xsl:param>
  212. <xsl:variable name="tokens" select="count($scope/varlistentry)"/>
  213. <xsl:variable name="token" select="$scope/varlistentry[$position]/term/token"/>
  214. <xsl:variable name="size" select="substring-before($token,' KB')"/>
  215. <xsl:variable name="rawsize">
  216. <xsl:choose>
  217. <xsl:when test="contains($size,',')">
  218. <xsl:value-of select="concat(substring-before($size,','),substring-after($size,','))"/>
  219. </xsl:when>
  220. <xsl:otherwise>
  221. <xsl:value-of select="$size"/>
  222. </xsl:otherwise>
  223. </xsl:choose>
  224. </xsl:variable>
  225. <xsl:choose>
  226. <xsl:when test="$position &lt;= $tokens">
  227. <xsl:call-template name="calculation">
  228. <xsl:with-param name="scope" select="$scope"/>
  229. <xsl:with-param name="position" select="$position +1"/>
  230. <xsl:with-param name="total" select="$total + $rawsize"/>
  231. </xsl:call-template>
  232. </xsl:when>
  233. <xsl:otherwise>
  234. <xsl:choose>
  235. <xsl:when test="$total &lt; '1000'">
  236. <xsl:value-of select="$total"/>
  237. <xsl:text> KB</xsl:text>
  238. </xsl:when>
  239. <xsl:when test="$total &gt; '1000' and $total &lt; '5000'">
  240. <xsl:value-of select="substring($total,1,1)"/>
  241. <xsl:text>,</xsl:text>
  242. <xsl:value-of select="substring($total,2)"/>
  243. <xsl:text> KB</xsl:text>
  244. </xsl:when>
  245. <xsl:otherwise>
  246. <xsl:value-of select="round($total div 1024)"/>
  247. <xsl:text> MB</xsl:text>
  248. </xsl:otherwise>
  249. </xsl:choose>
  250. </xsl:otherwise>
  251. </xsl:choose>
  252. </xsl:template>
  253. </xsl:stylesheet>