lfs-mixed.xsl 9.5 KB

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