lfs-mixed.xsl 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  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:choose>
  117. <xsl:when test="ancestor::para and not(descendant::ulink)">
  118. <xsl:call-template name="hyphenate-url">
  119. <xsl:with-param name="url">
  120. <xsl:apply-templates/>
  121. </xsl:with-param>
  122. </xsl:call-template>
  123. </xsl:when>
  124. <xsl:otherwise>
  125. <xsl:apply-templates/>
  126. </xsl:otherwise>
  127. </xsl:choose>
  128. </xsl:with-param>
  129. </xsl:call-template>
  130. </xsl:param>
  131. <fo:inline xsl:use-attribute-sets="monospace.properties">
  132. <xsl:if test="@dir">
  133. <xsl:attribute name="direction">
  134. <xsl:choose>
  135. <xsl:when test="@dir = 'ltr' or @dir = 'lro'">ltr</xsl:when>
  136. <xsl:otherwise>rtl</xsl:otherwise>
  137. </xsl:choose>
  138. </xsl:attribute>
  139. </xsl:if>
  140. <xsl:copy-of select="$content"/>
  141. </fo:inline>
  142. </xsl:template>
  143. <!-- inline.italicmonoseq:
  144. Added hyphenate-url support to parameter, replaceable, structfield,
  145. function/parameter, and function/replaceable -->
  146. <!-- The original template is in {docbook-xsl}/fo/inline.xsl -->
  147. <xsl:template name="inline.italicmonoseq">
  148. <xsl:param name="content">
  149. <xsl:call-template name="simple.xlink">
  150. <xsl:with-param name="content">
  151. <xsl:choose>
  152. <xsl:when test="ancestor::para and not(descendant::ulink)">
  153. <xsl:call-template name="hyphenate-url">
  154. <xsl:with-param name="url">
  155. <xsl:apply-templates/>
  156. </xsl:with-param>
  157. </xsl:call-template>
  158. </xsl:when>
  159. <xsl:otherwise>
  160. <xsl:apply-templates/>
  161. </xsl:otherwise>
  162. </xsl:choose>
  163. </xsl:with-param>
  164. </xsl:call-template>
  165. </xsl:param>
  166. <fo:inline font-style="italic" xsl:use-attribute-sets="monospace.properties">
  167. <xsl:call-template name="anchor"/>
  168. <xsl:if test="@dir">
  169. <xsl:attribute name="direction">
  170. <xsl:choose>
  171. <xsl:when test="@dir = 'ltr' or @dir = 'lro'">ltr</xsl:when>
  172. <xsl:otherwise>rtl</xsl:otherwise>
  173. </xsl:choose>
  174. </xsl:attribute>
  175. </xsl:if>
  176. <xsl:copy-of select="$content"/>
  177. </fo:inline>
  178. </xsl:template>
  179. <!-- Show external URLs in italic font -->
  180. <xsl:attribute-set name="xref.properties">
  181. <xsl:attribute name="font-style">
  182. <xsl:choose>
  183. <xsl:when test="self::ulink">italic</xsl:when>
  184. <xsl:otherwise>inherit</xsl:otherwise>
  185. </xsl:choose>
  186. </xsl:attribute>
  187. </xsl:attribute-set>
  188. <!-- Lists -->
  189. <!-- What spacing do you want before and after lists? -->
  190. <xsl:attribute-set name="list.block.spacing">
  191. <xsl:attribute name="space-before.optimum">0.6em</xsl:attribute>
  192. <xsl:attribute name="space-before.minimum">0.4em</xsl:attribute>
  193. <xsl:attribute name="space-before.maximum">0.8em</xsl:attribute>
  194. <xsl:attribute name="space-after.optimum">0.6em</xsl:attribute>
  195. <xsl:attribute name="space-after.minimum">0.4em</xsl:attribute>
  196. <xsl:attribute name="space-after.maximum">0.8em</xsl:attribute>
  197. </xsl:attribute-set>
  198. <!-- What spacing do you want between list items? -->
  199. <xsl:attribute-set name="list.item.spacing">
  200. <xsl:attribute name="space-before.optimum">0.4em</xsl:attribute>
  201. <xsl:attribute name="space-before.minimum">0.2em</xsl:attribute>
  202. <xsl:attribute name="space-before.maximum">0.6em</xsl:attribute>
  203. </xsl:attribute-set>
  204. <!-- Properties that apply to each list-block generated by itemizedlist. -->
  205. <xsl:attribute-set name="itemizedlist.properties"
  206. use-attribute-sets="list.block.properties">
  207. <xsl:attribute name="text-align">left</xsl:attribute>
  208. </xsl:attribute-set>
  209. <!-- Format variablelists lists as blocks? 1 = yes, 0 = no
  210. Default variablelist format. We override it when necesary
  211. using the list-presentation processing instruction. -->
  212. <xsl:param name="variablelist.as.blocks" select="1"/>
  213. <!-- Specifies the longest term in variablelists.
  214. Used when list-presentation = list -->
  215. <xsl:param name="variablelist.max.termlength">32</xsl:param>
  216. <!-- varlistentry mode block:
  217. Addibg a bullet, left alignament, and @kepp-*.* attributes
  218. for packages and paches list. -->
  219. <!-- The original template is in {docbook-xsl}/fo/list.xsl -->
  220. <xsl:template match="varlistentry" mode="vl.as.blocks">
  221. <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
  222. <xsl:choose>
  223. <xsl:when test="ancestor::variablelist/@role = 'materials'">
  224. <fo:block id="{$id}" xsl:use-attribute-sets="list.item.spacing"
  225. keep-together.within-column="always"
  226. keep-with-next.within-column="always" text-align="left">
  227. <xsl:text>&#x2022; </xsl:text>
  228. <xsl:apply-templates select="term"/>
  229. </fo:block>
  230. <fo:block margin-left="1.4pc" text-align="left"
  231. keep-together.within-column="always"
  232. keep-with-previous.within-column="always">
  233. <xsl:apply-templates select="listitem"/>
  234. </fo:block>
  235. </xsl:when>
  236. <xsl:otherwise>
  237. <fo:block id="{$id}" xsl:use-attribute-sets="list.item.spacing"
  238. keep-together.within-column="always"
  239. keep-with-next.within-column="always">
  240. <xsl:apply-templates select="term"/>
  241. </fo:block>
  242. <fo:block margin-left="0.25in">
  243. <xsl:apply-templates select="listitem"/>
  244. </fo:block>
  245. </xsl:otherwise>
  246. </xsl:choose>
  247. </xsl:template>
  248. <!-- segmentedlist:
  249. Making it an actual FO list to can indent items.
  250. Adjust vertical space. -->
  251. <!-- The original template is in {docbook-xsl}/fo/list.xsl -->
  252. <xsl:template match="segmentedlist">
  253. <fo:list-block provisional-distance-between-starts="12em"
  254. provisional-label-separation="1em"
  255. keep-together.within-column="always">
  256. <xsl:choose>
  257. <xsl:when test="ancestor::appendix[@id='appendixc']">
  258. <xsl:attribute name="space-before.optimum">0.2em</xsl:attribute>
  259. <xsl:attribute name="space-before.minimum">0em</xsl:attribute>
  260. <xsl:attribute name="space-before.maximum">0.4em</xsl:attribute>
  261. <xsl:attribute name="space-after.optimum">0.2em</xsl:attribute>
  262. <xsl:attribute name="space-after.minimum">0em</xsl:attribute>
  263. <xsl:attribute name="space-after.maximum">0.4em</xsl:attribute>
  264. <xsl:attribute name="keep-with-previous.within-column">always</xsl:attribute>
  265. </xsl:when>
  266. <xsl:otherwise>
  267. <xsl:attribute name="space-before.optimum">0.4em</xsl:attribute>
  268. <xsl:attribute name="space-before.minimum">0.2em</xsl:attribute>
  269. <xsl:attribute name="space-before.maximum">0.6em</xsl:attribute>
  270. <xsl:attribute name="space-after.optimum">0.4em</xsl:attribute>
  271. <xsl:attribute name="space-after.minimum">0.2em</xsl:attribute>
  272. <xsl:attribute name="space-after.maximum">0.6em</xsl:attribute>
  273. </xsl:otherwise>
  274. </xsl:choose>
  275. <xsl:apply-templates select="seglistitem/seg"/>
  276. </fo:list-block>
  277. </xsl:template>
  278. <!-- seg:
  279. Self-made template based on the original seg template
  280. found in {docbook-xsl}/fo/list.xsl
  281. Making segmentedlist an actual FO list to can indent items. -->
  282. <xsl:template match="seglistitem/seg">
  283. <xsl:variable name="segnum" select="count(preceding-sibling::seg)+1"/>
  284. <xsl:variable name="seglist" select="ancestor::segmentedlist"/>
  285. <xsl:variable name="segtitles" select="$seglist/segtitle"/>
  286. <fo:list-item xsl:use-attribute-sets="compact.list.item.spacing">
  287. <fo:list-item-label end-indent="label-end()" text-align="start">
  288. <fo:block>
  289. <fo:inline font-weight="bold">
  290. <xsl:apply-templates select="$segtitles[$segnum=position()]"
  291. mode="segtitle-in-seg"/>
  292. <xsl:text>:</xsl:text>
  293. </fo:inline>
  294. </fo:block>
  295. </fo:list-item-label>
  296. <fo:list-item-body start-indent="body-start()">
  297. <fo:block>
  298. <xsl:apply-templates/>
  299. </fo:block>
  300. </fo:list-item-body>
  301. </fo:list-item>
  302. </xsl:template>
  303. </xsl:stylesheet>