lfs-mixed.xsl 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. <?xml version='1.0' encoding='ISO-8859-1'?>
  2. <!--
  3. $LastChangedBy$
  4. $Date$
  5. -->
  6. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  7. xmlns:fo="http://www.w3.org/1999/XSL/Format"
  8. version="1.0">
  9. <!-- This stylesheet contains misc params, attribute sets and templates
  10. for output formating.
  11. This file is for that templates that don't fit in other files. -->
  12. <!-- What space do you want between normal paragraphs. -->
  13. <xsl:attribute-set name="normal.para.spacing">
  14. <xsl:attribute name="space-before.optimum">0.6em</xsl:attribute>
  15. <xsl:attribute name="space-before.minimum">0.4em</xsl:attribute>
  16. <xsl:attribute name="space-before.maximum">0.8em</xsl:attribute>
  17. <xsl:attribute name="orphans">3</xsl:attribute>
  18. <xsl:attribute name="widows">3</xsl:attribute>
  19. </xsl:attribute-set>
  20. <!-- Properties associated with verbatim text. -->
  21. <xsl:attribute-set name="verbatim.properties">
  22. <xsl:attribute name="keep-with-previous.within-column">always</xsl:attribute>
  23. <xsl:attribute name="space-before.optimum">0.6em</xsl:attribute>
  24. <xsl:attribute name="space-before.minimum">0.4em</xsl:attribute>
  25. <xsl:attribute name="space-before.maximum">0.8em</xsl:attribute>
  26. <xsl:attribute name="space-after.optimum">0.6em</xsl:attribute>
  27. <xsl:attribute name="space-after.minimum">0.4em</xsl:attribute>
  28. <xsl:attribute name="space-after.maximum">0.8em</xsl:attribute>
  29. <xsl:attribute name="hyphenate">false</xsl:attribute>
  30. <xsl:attribute name="wrap-option">no-wrap</xsl:attribute>
  31. <xsl:attribute name="white-space-collapse">false</xsl:attribute>
  32. <xsl:attribute name="white-space-treatment">preserve</xsl:attribute>
  33. <xsl:attribute name="linefeed-treatment">preserve</xsl:attribute>
  34. <xsl:attribute name="text-align">start</xsl:attribute>
  35. </xsl:attribute-set>
  36. <!-- Should verbatim environments be shaded? 1 =yes, 0 = no -->
  37. <xsl:param name="shade.verbatim" select="1"/>
  38. <!-- Properties that specify the style of shaded verbatim listings -->
  39. <xsl:attribute-set name="shade.verbatim.style">
  40. <xsl:attribute name="background-color">#E9E9E9</xsl:attribute>
  41. <xsl:attribute name="border-style">solid</xsl:attribute>
  42. <xsl:attribute name="border-width">0.5pt</xsl:attribute>
  43. <xsl:attribute name="border-color">#888</xsl:attribute>
  44. <xsl:attribute name="padding-start">5pt</xsl:attribute>
  45. <xsl:attribute name="padding-top">2pt</xsl:attribute>
  46. <xsl:attribute name="padding-bottom">2pt</xsl:attribute>
  47. </xsl:attribute-set>
  48. <!-- para:
  49. Skip empty "Home page" in packages.xml.
  50. Allow forced line breaks inside paragraphs emulating literallayout.
  51. Removed vertical space in variablelist. -->
  52. <!-- The original template is in {docbook-xsl}/fo/block.xsl -->
  53. <xsl:template match="para">
  54. <xsl:choose>
  55. <xsl:when test="child::ulink[@url=' ']"/>
  56. <xsl:when test="./@remap='verbatim'">
  57. <fo:block xsl:use-attribute-sets="verbatim.properties">
  58. <xsl:call-template name="anchor"/>
  59. <xsl:apply-templates/>
  60. </fo:block>
  61. </xsl:when>
  62. <xsl:when test="ancestor::variablelist">
  63. <fo:block>
  64. <xsl:attribute name="space-before.optimum">0.1em</xsl:attribute>
  65. <xsl:attribute name="space-before.minimum">0em</xsl:attribute>
  66. <xsl:attribute name="space-before.maximum">0.2em</xsl:attribute>
  67. <xsl:call-template name="anchor"/>
  68. <xsl:apply-templates/>
  69. </fo:block>
  70. </xsl:when>
  71. <xsl:otherwise>
  72. <fo:block xsl:use-attribute-sets="normal.para.spacing">
  73. <xsl:call-template name="anchor"/>
  74. <xsl:apply-templates/>
  75. </fo:block>
  76. </xsl:otherwise>
  77. </xsl:choose>
  78. </xsl:template>
  79. <!-- screen, literallayout:
  80. Self-made template that creates a fo:block wrapper with keep-together
  81. processing instruction support around the output generated by
  82. original screen templates. -->
  83. <xsl:template match="screen|literallayout">
  84. <xsl:variable name="keep.together">
  85. <xsl:call-template name="pi.dbfo_keep-together"/>
  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(ancestor::screen)
  118. and not(descendant::ulink)">
  119. <xsl:call-template name="hyphenate-url">
  120. <xsl:with-param name="url">
  121. <xsl:apply-templates/>
  122. </xsl:with-param>
  123. </xsl:call-template>
  124. </xsl:when>
  125. <xsl:otherwise>
  126. <xsl:apply-templates/>
  127. </xsl:otherwise>
  128. </xsl:choose>
  129. </xsl:with-param>
  130. </xsl:call-template>
  131. </xsl:param>
  132. <fo:inline xsl:use-attribute-sets="monospace.properties">
  133. <xsl:if test="@dir">
  134. <xsl:attribute name="direction">
  135. <xsl:choose>
  136. <xsl:when test="@dir = 'ltr' or @dir = 'lro'">ltr</xsl:when>
  137. <xsl:otherwise>rtl</xsl:otherwise>
  138. </xsl:choose>
  139. </xsl:attribute>
  140. </xsl:if>
  141. <xsl:copy-of select="$content"/>
  142. </fo:inline>
  143. </xsl:template>
  144. <!-- inline.italicmonoseq:
  145. Added hyphenate-url support to parameter, replaceable, structfield,
  146. function/parameter, and function/replaceable -->
  147. <!-- The original template is in {docbook-xsl}/fo/inline.xsl -->
  148. <xsl:template name="inline.italicmonoseq">
  149. <xsl:param name="content">
  150. <xsl:call-template name="simple.xlink">
  151. <xsl:with-param name="content">
  152. <xsl:choose>
  153. <xsl:when test="ancestor::para and not(ancestor::screen)
  154. and not(descendant::ulink)">
  155. <xsl:call-template name="hyphenate-url">
  156. <xsl:with-param name="url">
  157. <xsl:apply-templates/>
  158. </xsl:with-param>
  159. </xsl:call-template>
  160. </xsl:when>
  161. <xsl:otherwise>
  162. <xsl:apply-templates/>
  163. </xsl:otherwise>
  164. </xsl:choose>
  165. </xsl:with-param>
  166. </xsl:call-template>
  167. </xsl:param>
  168. <fo:inline font-style="italic" xsl:use-attribute-sets="monospace.properties">
  169. <xsl:call-template name="anchor"/>
  170. <xsl:if test="@dir">
  171. <xsl:attribute name="direction">
  172. <xsl:choose>
  173. <xsl:when test="@dir = 'ltr' or @dir = 'lro'">ltr</xsl:when>
  174. <xsl:otherwise>rtl</xsl:otherwise>
  175. </xsl:choose>
  176. </xsl:attribute>
  177. </xsl:if>
  178. <xsl:copy-of select="$content"/>
  179. </fo:inline>
  180. </xsl:template>
  181. <!-- Show external URLs in italic font -->
  182. <xsl:attribute-set name="xref.properties">
  183. <xsl:attribute name="font-style">
  184. <xsl:choose>
  185. <xsl:when test="self::ulink">italic</xsl:when>
  186. <xsl:otherwise>inherit</xsl:otherwise>
  187. </xsl:choose>
  188. </xsl:attribute>
  189. </xsl:attribute-set>
  190. <!-- Center table title. -->
  191. <xsl:attribute-set name="formal.title.properties">
  192. <xsl:attribute name="text-align">
  193. <xsl:choose>
  194. <xsl:when test="local-name(.) = 'table'">center</xsl:when>
  195. <xsl:otherwise>left</xsl:otherwise>
  196. </xsl:choose>
  197. </xsl:attribute>
  198. </xsl:attribute-set>
  199. <!-- table.layout:
  200. We want all tables centered. Based on a hack posted
  201. by Ellen Juhlin on docbook-apps mailing list. -->
  202. <!-- The original template is in {docbook-xsl}/fo/table.xsl -->
  203. <xsl:template name="table.layout">
  204. <xsl:param name="table.content" select="NOTANODE"/>
  205. <fo:table table-layout="fixed" width="100%">
  206. <fo:table-column column-width ="proportional-column-width(1)"/>
  207. <fo:table-column>
  208. <!-- Set center column width equal to table width -->
  209. <xsl:attribute name="column-width">
  210. <xsl:call-template name="table.width"/>
  211. </xsl:attribute>
  212. </fo:table-column>
  213. <fo:table-column column-width ="proportional-column-width(1)"/>
  214. <fo:table-body>
  215. <fo:table-row>
  216. <fo:table-cell column-number="2">
  217. <xsl:copy-of select="$table.content"/>
  218. </fo:table-cell>
  219. </fo:table-row>
  220. </fo:table-body>
  221. </fo:table>
  222. </xsl:template>
  223. <!-- Revision History -->
  224. <!-- revhistory titlepage:
  225. Self-made template to add missing support on bookinfo. -->
  226. <xsl:template match="revhistory" mode="book.titlepage.verso.auto.mode">
  227. <fo:block space-before.optimum="2em"
  228. space-before.minimum="1.5em"
  229. space-before.maximum="2.5em">
  230. <xsl:apply-templates select="." mode="book.titlepage.verso.mode"/>
  231. </fo:block>
  232. </xsl:template>
  233. <!-- revhitory title properties -->
  234. <xsl:attribute-set name="revhistory.title.properties">
  235. <xsl:attribute name="text-align">center</xsl:attribute>
  236. <xsl:attribute name="font-weight">bold</xsl:attribute>
  237. </xsl:attribute-set>
  238. <!-- revhistory/revision mode titlepage.mode:
  239. Removed authorinitials | author support placing
  240. revremark | revdescription instead on that table-cell. -->
  241. <!-- The original template is in {docbook-xsl}/fo/titlepage.xsl -->
  242. <xsl:template match="revhistory/revision" mode="titlepage.mode">
  243. <xsl:variable name="revnumber" select="revnumber"/>
  244. <xsl:variable name="revdate" select="date"/>
  245. <xsl:variable name="revremark" select="revremark|revdescription"/>
  246. <fo:table-row>
  247. <fo:table-cell xsl:use-attribute-sets="revhistory.table.cell.properties">
  248. <fo:block>
  249. <xsl:if test="$revnumber">
  250. <xsl:call-template name="gentext">
  251. <xsl:with-param name="key" select="'Revision'"/>
  252. </xsl:call-template>
  253. <xsl:call-template name="gentext.space"/>
  254. <xsl:apply-templates select="$revnumber[1]" mode="titlepage.mode"/>
  255. </xsl:if>
  256. </fo:block>
  257. </fo:table-cell>
  258. <fo:table-cell xsl:use-attribute-sets="revhistory.table.cell.properties">
  259. <fo:block>
  260. <xsl:apply-templates select="$revdate[1]"/>
  261. </fo:block>
  262. </fo:table-cell>
  263. <fo:table-cell xsl:use-attribute-sets="revhistory.table.cell.properties">
  264. <fo:block>
  265. <xsl:apply-templates select="$revremark[1]"/>
  266. </fo:block>
  267. </fo:table-cell>
  268. </fo:table-row>
  269. </xsl:template>
  270. <!-- Dummy sect1 -->
  271. <!-- sect1:
  272. Self-made template to skip dummy sect1 pages generation. -->
  273. <xsl:template match="sect1">
  274. <xsl:choose>
  275. <xsl:when test="@role = 'dummy'"/>
  276. <xsl:otherwise>
  277. <xsl:apply-imports/>
  278. </xsl:otherwise>
  279. </xsl:choose>
  280. </xsl:template>
  281. <!-- sect1 mode fop1.outline:
  282. Self-made template to skip dummy sect1 bookmarks generation. -->
  283. <xsl:template match="sect1" mode="fop1.outline">
  284. <xsl:choose>
  285. <xsl:when test="@role = 'dummy'"/>
  286. <xsl:otherwise>
  287. <xsl:apply-imports/>
  288. </xsl:otherwise>
  289. </xsl:choose>
  290. </xsl:template>
  291. <!-- toc.line:
  292. For dummy sect1 output only the title. -->
  293. <!-- The original template is in {docbook-xsl}/fo/autotoc.xsl -->
  294. <xsl:template name="toc.line">
  295. <xsl:param name="toc-context" select="NOTANODE"/>
  296. <xsl:variable name="id">
  297. <xsl:call-template name="object.id"/>
  298. </xsl:variable>
  299. <xsl:variable name="label">
  300. <xsl:apply-templates select="." mode="label.markup"/>
  301. </xsl:variable>
  302. <xsl:choose>
  303. <xsl:when test="@role = 'dummy'">
  304. <fo:block text-align="left">
  305. <xsl:apply-templates select="." mode="titleabbrev.markup"/>
  306. </fo:block>
  307. </xsl:when>
  308. <xsl:otherwise>
  309. <fo:block xsl:use-attribute-sets="toc.line.properties">
  310. <fo:inline keep-with-next.within-line="always">
  311. <fo:basic-link internal-destination="{$id}">
  312. <xsl:if test="$label != ''">
  313. <xsl:copy-of select="$label"/>
  314. <xsl:value-of select="$autotoc.label.separator"/>
  315. </xsl:if>
  316. <xsl:apply-templates select="." mode="titleabbrev.markup"/>
  317. </fo:basic-link>
  318. </fo:inline>
  319. <fo:inline keep-together.within-line="always">
  320. <xsl:text> </xsl:text>
  321. <fo:leader leader-pattern="dots"
  322. leader-pattern-width="3pt"
  323. leader-alignment="reference-area"
  324. keep-with-next.within-line="always"/>
  325. <xsl:text> </xsl:text>
  326. <fo:basic-link internal-destination="{$id}">
  327. <fo:page-number-citation ref-id="{$id}"/>
  328. </fo:basic-link>
  329. </fo:inline>
  330. </fo:block>
  331. </xsl:otherwise>
  332. </xsl:choose>
  333. </xsl:template>
  334. </xsl:stylesheet>