lfs-mixed.xsl 11 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. <!-- Allow forced line breaks inside paragraphs emulating literallayout
  6. and to remove vertical space in pachages and patches pages. -->
  7. <xsl:template match="para">
  8. <xsl:choose>
  9. <xsl:when test="child::ulink[@url=' ']"/>
  10. <xsl:when test="./@remap='verbatim'">
  11. <fo:block wrap-option="no-wrap"
  12. white-space-collapse="false"
  13. white-space-treatment="preserve"
  14. text-align="start"
  15. linefeed-treatment="preserve">
  16. <xsl:call-template name="anchor"/>
  17. <xsl:apply-templates/>
  18. </fo:block>
  19. </xsl:when>
  20. <xsl:when test="ancestor::variablelist/@role = 'materials'">
  21. <fo:block>
  22. <xsl:attribute name="space-before.optimum">0.1em</xsl:attribute>
  23. <xsl:attribute name="space-before.minimum">0em</xsl:attribute>
  24. <xsl:attribute name="space-before.maximum">0.2em</xsl:attribute>
  25. <xsl:call-template name="anchor"/>
  26. <xsl:apply-templates/>
  27. </fo:block>
  28. </xsl:when>
  29. <xsl:otherwise>
  30. <xsl:apply-imports/>
  31. </xsl:otherwise>
  32. </xsl:choose>
  33. </xsl:template>
  34. <!-- Show URLs in italic font -->
  35. <xsl:template match="ulink" name="ulink">
  36. <fo:inline font-style="italic">
  37. <fo:basic-link xsl:use-attribute-sets="xref.properties">
  38. <xsl:attribute name="external-destination">
  39. <xsl:call-template name="fo-external-image">
  40. <xsl:with-param name="filename" select="@url"/>
  41. </xsl:call-template>
  42. </xsl:attribute>
  43. <xsl:choose>
  44. <xsl:when test="count(child::node())=0">
  45. <xsl:call-template name="hyphenate-url">
  46. <xsl:with-param name="url" select="@url"/>
  47. </xsl:call-template>
  48. </xsl:when>
  49. <xsl:otherwise>
  50. <xsl:apply-templates/>
  51. </xsl:otherwise>
  52. </xsl:choose>
  53. </fo:basic-link>
  54. </fo:inline>
  55. <xsl:if test="count(child::node()) != 0
  56. and string(.) != @url
  57. and $ulink.show != 0">
  58. <!-- yes, show the URI -->
  59. <xsl:choose>
  60. <xsl:when test="$ulink.footnotes != 0 and not(ancestor::footnote)">
  61. <xsl:text>&#xA0;</xsl:text>
  62. <fo:footnote>
  63. <xsl:call-template name="ulink.footnote.number"/>
  64. <fo:footnote-body font-family="{$body.fontset}"
  65. font-size="{$footnote.font.size}">
  66. <fo:block>
  67. <xsl:call-template name="ulink.footnote.number"/>
  68. <xsl:text> </xsl:text>
  69. <fo:inline>
  70. <xsl:value-of select="@url"/>
  71. </fo:inline>
  72. </fo:block>
  73. </fo:footnote-body>
  74. </fo:footnote>
  75. </xsl:when>
  76. <xsl:otherwise>
  77. <fo:inline hyphenate="false">
  78. <xsl:text> [</xsl:text>
  79. <xsl:call-template name="hyphenate-url">
  80. <xsl:with-param name="url" select="@url"/>
  81. </xsl:call-template>
  82. <xsl:text>]</xsl:text>
  83. </fo:inline>
  84. </xsl:otherwise>
  85. </xsl:choose>
  86. </xsl:if>
  87. </xsl:template>
  88. <!-- Split URLs (obsolete, keeped as reference) -->
  89. <!--<xsl:template name="hyphenate-url">
  90. <xsl:param name="url" select="''"/>
  91. <xsl:choose>
  92. <xsl:when test="ancestor::varlistentry">
  93. <xsl:choose>
  94. <xsl:when test="string-length($url) > 90">
  95. <xsl:value-of select="substring($url, 1, 50)"/>
  96. <xsl:param name="rest" select="substring($url, 51)"/>
  97. <xsl:value-of select="substring-before($rest, '/')"/>
  98. <xsl:text> /</xsl:text>
  99. <xsl:value-of select="substring-after($rest, '/')"/>
  100. </xsl:when>
  101. <xsl:otherwise>
  102. <xsl:value-of select="$url"/>
  103. </xsl:otherwise>
  104. </xsl:choose>
  105. </xsl:when>
  106. <xsl:otherwise>
  107. <xsl:value-of select="$url"/>-->
  108. <!-- <xsl:value-of select="substring-before($url, '//')"/>
  109. <xsl:text>// </xsl:text>
  110. <xsl:call-template name="split-url">
  111. <xsl:with-param name="url2" select="substring-after($url, '//')"/>
  112. </xsl:call-template>-->
  113. <!-- </xsl:otherwise>
  114. </xsl:choose>
  115. </xsl:template>-->
  116. <!--<xsl:template name="split-url">
  117. <xsl:choose>
  118. <xsl:when test="contains($url2, '/')">
  119. <xsl:param name="url2" select="''"/>
  120. <xsl:value-of select="substring-before($url2, '/')"/>
  121. <xsl:text> /</xsl:text>
  122. <xsl:call-template name="split-url">
  123. <xsl:with-param name="url2" select="substring-after($url2, '/')"/>
  124. </xsl:call-template>
  125. </xsl:when>
  126. <xsl:otherwise>
  127. <xsl:value-of select="$url2"/>
  128. </xsl:otherwise>
  129. </xsl:choose>
  130. </xsl:template>-->
  131. <!-- Shade screen -->
  132. <xsl:param name="shade.verbatim" select="1"/>
  133. <!-- How is rendered by default a variablelist -->
  134. <xsl:param name="variablelist.as.blocks" select="1"/>
  135. <xsl:param name="variablelist.max.termlength">32</xsl:param>
  136. <!-- Adding space before segmentedlist -->
  137. <xsl:template match="segmentedlist">
  138. <!--<xsl:variable name="presentation">
  139. <xsl:call-template name="pi-attribute">
  140. <xsl:with-param name="pis"
  141. select="processing-instruction('dbfo')"/>
  142. <xsl:with-param name="attribute" select="'list-presentation'"/>
  143. </xsl:call-template>
  144. </xsl:variable>
  145. <xsl:choose>
  146. <xsl:when test="$presentation = 'table'">
  147. <xsl:apply-templates select="." mode="seglist-table"/>
  148. </xsl:when>
  149. <xsl:when test="$presentation = 'list'">
  150. <fo:block space-before.minimum="0.4em" space-before.optimum="0.6em"
  151. space-before.maximum="0.8em">
  152. <xsl:apply-templates/>
  153. </fo:block>
  154. </xsl:when>
  155. <xsl:when test="$segmentedlist.as.table != 0">
  156. <xsl:apply-templates select="." mode="seglist-table"/>
  157. </xsl:when>
  158. <xsl:otherwise>-->
  159. <fo:block space-before.minimum="0.4em" space-before.optimum="0.6em"
  160. space-before.maximum="0.8em">
  161. <xsl:apply-templates/>
  162. </fo:block>
  163. <!--</xsl:otherwise>
  164. </xsl:choose>-->
  165. </xsl:template>
  166. <!-- Presentation of literal tag -->
  167. <xsl:template match="literal">
  168. <fo:inline font-weight="normal">
  169. <xsl:call-template name="inline.monoseq"/>
  170. </fo:inline>
  171. </xsl:template>
  172. <!-- Left alingnament for itemizedlist -->
  173. <xsl:template match="itemizedlist">
  174. <xsl:variable name="id">
  175. <xsl:call-template name="object.id"/>
  176. </xsl:variable>
  177. <xsl:variable name="label-width">
  178. <xsl:call-template name="dbfo-attribute">
  179. <xsl:with-param name="pis"
  180. select="processing-instruction('dbfo')"/>
  181. <xsl:with-param name="attribute" select="'label-width'"/>
  182. </xsl:call-template>
  183. </xsl:variable>
  184. <xsl:if test="title">
  185. <xsl:apply-templates select="title" mode="list.title.mode"/>
  186. </xsl:if>
  187. <!-- Preserve order of PIs and comments -->
  188. <xsl:apply-templates
  189. select="*[not(self::listitem
  190. or self::title
  191. or self::titleabbrev)]
  192. |comment()[not(preceding-sibling::listitem)]
  193. |processing-instruction()[not(preceding-sibling::listitem)]"/>
  194. <fo:list-block id="{$id}" xsl:use-attribute-sets="list.block.spacing"
  195. provisional-label-separation="0.2em" text-align="left">
  196. <xsl:attribute name="provisional-distance-between-starts">
  197. <xsl:choose>
  198. <xsl:when test="$label-width != ''">
  199. <xsl:value-of select="$label-width"/>
  200. </xsl:when>
  201. <xsl:otherwise>1.5em</xsl:otherwise>
  202. </xsl:choose>
  203. </xsl:attribute>
  204. <xsl:apply-templates
  205. select="listitem
  206. |comment()[preceding-sibling::listitem]
  207. |processing-instruction()[preceding-sibling::listitem]"/>
  208. </fo:list-block>
  209. </xsl:template>
  210. <!-- Addibg a bullet, and left alignament, for packages and paches list. -->
  211. <xsl:template match="varlistentry" mode="vl.as.blocks">
  212. <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
  213. <xsl:choose>
  214. <xsl:when test="ancestor::variablelist/@role = 'materials'">
  215. <fo:block id="{$id}" xsl:use-attribute-sets="list.item.spacing"
  216. keep-together.within-column="always"
  217. keep-with-next.within-column="always" text-align="left">
  218. <xsl:text>&#x2022; </xsl:text>
  219. <xsl:apply-templates select="term"/>
  220. </fo:block>
  221. <fo:block margin-left="1.4pc" text-align="left">
  222. <xsl:apply-templates select="listitem"/>
  223. </fo:block>
  224. </xsl:when>
  225. <xsl:otherwise>
  226. <fo:block id="{$id}" xsl:use-attribute-sets="list.item.spacing"
  227. keep-together.within-column="always"
  228. keep-with-next.within-column="always">
  229. <xsl:apply-templates select="term"/>
  230. </fo:block>
  231. <fo:block margin-left="0.25in">
  232. <xsl:apply-templates select="listitem"/>
  233. </fo:block>
  234. </xsl:otherwise>
  235. </xsl:choose>
  236. </xsl:template>
  237. <!-- Total packages size calculation -->
  238. <xsl:template match="returnvalue">
  239. <xsl:call-template name="calculation">
  240. <xsl:with-param name="scope" select="../../variablelist"/>
  241. </xsl:call-template>
  242. </xsl: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>