lfs-mixed.xsl 14 KB

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