lfs-mixed.xsl 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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. <!-- The following section has been modified by Martin Miehe. Page breaks
  94. should be allowed within the long script listings in the appendices.
  95. <xsl:otherwise>always</xsl:otherwise>
  96. -->
  97. <xsl:otherwise>
  98. <xsl:choose>
  99. <xsl:when test="ancestor::appendix">auto</xsl:when>
  100. <!-- Modified by Bruce Dubbs. Allow user to specify
  101. automatic screen formatting to split across pages. -->
  102. <xsl:when test="@role='auto'">auto</xsl:when>
  103. <xsl:otherwise>always</xsl:otherwise>
  104. </xsl:choose>
  105. </xsl:otherwise>
  106. <!-- End of modification -->
  107. </xsl:choose>
  108. </xsl:attribute>
  109. <!-- The following lines were inserted by Martin Miehe. Scripts and rules
  110. in the appendices should have a smaller font-size so that at least
  111. 80 characters fit to one line. -->
  112. <xsl:if test="ancestor::appendix"> <!-- name(/) != appendix" -->
  113. <xsl:attribute name="font-size">10pt</xsl:attribute>
  114. </xsl:if>
  115. <!-- End of insertion. -->
  116. <xsl:apply-imports/>
  117. </fo:block>
  118. </xsl:template>
  119. <!-- literal:
  120. Be sure that literal will use allways normal font weight. -->
  121. <!-- The original template is in {docbook-xsl}/fo/inline.xsl -->
  122. <xsl:template match="literal">
  123. <fo:inline font-weight="normal">
  124. <xsl:call-template name="inline.monoseq"/>
  125. </fo:inline>
  126. </xsl:template>
  127. <!-- inline.monoseq:
  128. Added hyphenate-url support to classname, exceptionname, interfacename,
  129. methodname, computeroutput, constant, envar, filename, function, code,
  130. literal, option, promt, systemitem, varname, sgmltag, tag, and uri -->
  131. <!-- The original template is in {docbook-xsl}/fo/inline.xsl -->
  132. <xsl:template name="inline.monoseq">
  133. <xsl:param name="content">
  134. <xsl:call-template name="simple.xlink">
  135. <xsl:with-param name="content">
  136. <xsl:choose>
  137. <xsl:when test="ancestor::para and not(ancestor::screen)
  138. and not(descendant::ulink)">
  139. <xsl:call-template name="hyphenate-url">
  140. <xsl:with-param name="url">
  141. <xsl:apply-templates/>
  142. </xsl:with-param>
  143. </xsl:call-template>
  144. </xsl:when>
  145. <xsl:otherwise>
  146. <xsl:apply-templates/>
  147. </xsl:otherwise>
  148. </xsl:choose>
  149. </xsl:with-param>
  150. </xsl:call-template>
  151. </xsl:param>
  152. <fo:inline xsl:use-attribute-sets="monospace.properties">
  153. <xsl:if test="@dir">
  154. <xsl:attribute name="direction">
  155. <xsl:choose>
  156. <xsl:when test="@dir = 'ltr' or @dir = 'lro'">ltr</xsl:when>
  157. <xsl:otherwise>rtl</xsl:otherwise>
  158. </xsl:choose>
  159. </xsl:attribute>
  160. </xsl:if>
  161. <xsl:copy-of select="$content"/>
  162. </fo:inline>
  163. </xsl:template>
  164. <!-- inline.italicmonoseq:
  165. Added hyphenate-url support to parameter, replaceable, structfield,
  166. function/parameter, and function/replaceable -->
  167. <!-- The original template is in {docbook-xsl}/fo/inline.xsl -->
  168. <xsl:template name="inline.italicmonoseq">
  169. <xsl:param name="content">
  170. <xsl:call-template name="simple.xlink">
  171. <xsl:with-param name="content">
  172. <xsl:choose>
  173. <xsl:when test="ancestor::para and not(ancestor::screen)
  174. and not(descendant::ulink)">
  175. <xsl:call-template name="hyphenate-url">
  176. <xsl:with-param name="url">
  177. <xsl:apply-templates/>
  178. </xsl:with-param>
  179. </xsl:call-template>
  180. </xsl:when>
  181. <xsl:otherwise>
  182. <xsl:apply-templates/>
  183. </xsl:otherwise>
  184. </xsl:choose>
  185. </xsl:with-param>
  186. </xsl:call-template>
  187. </xsl:param>
  188. <fo:inline font-style="italic" xsl:use-attribute-sets="monospace.properties">
  189. <xsl:call-template name="anchor"/>
  190. <xsl:if test="@dir">
  191. <xsl:attribute name="direction">
  192. <xsl:choose>
  193. <xsl:when test="@dir = 'ltr' or @dir = 'lro'">ltr</xsl:when>
  194. <xsl:otherwise>rtl</xsl:otherwise>
  195. </xsl:choose>
  196. </xsl:attribute>
  197. </xsl:if>
  198. <xsl:copy-of select="$content"/>
  199. </fo:inline>
  200. </xsl:template>
  201. <!-- Show external URLs in italic font -->
  202. <xsl:attribute-set name="xref.properties">
  203. <xsl:attribute name="font-style">
  204. <xsl:choose>
  205. <xsl:when test="self::ulink">italic</xsl:when>
  206. <xsl:otherwise>inherit</xsl:otherwise>
  207. </xsl:choose>
  208. </xsl:attribute>
  209. </xsl:attribute-set>
  210. <!-- Center table title. -->
  211. <xsl:attribute-set name="formal.title.properties">
  212. <xsl:attribute name="text-align">
  213. <xsl:choose>
  214. <xsl:when test="local-name(.) = 'table'">center</xsl:when>
  215. <xsl:otherwise>left</xsl:otherwise>
  216. </xsl:choose>
  217. </xsl:attribute>
  218. </xsl:attribute-set>
  219. <!-- table.layout:
  220. We want all tables centered. Based on a hack posted
  221. by Ellen Juhlin on docbook-apps mailing list. -->
  222. <!-- The original template is in {docbook-xsl}/fo/table.xsl -->
  223. <xsl:template name="table.layout">
  224. <xsl:param name="table.content" select="NOTANODE"/>
  225. <fo:table table-layout="fixed" width="100%">
  226. <fo:table-column column-width ="proportional-column-width(1)"/>
  227. <fo:table-column>
  228. <!-- Set center column width equal to table width -->
  229. <xsl:attribute name="column-width">
  230. <xsl:call-template name="table.width"/>
  231. </xsl:attribute>
  232. </fo:table-column>
  233. <fo:table-column column-width ="proportional-column-width(1)"/>
  234. <fo:table-body>
  235. <fo:table-row>
  236. <fo:table-cell column-number="2">
  237. <xsl:copy-of select="$table.content"/>
  238. </fo:table-cell>
  239. </fo:table-row>
  240. </fo:table-body>
  241. </fo:table>
  242. </xsl:template>
  243. <!-- Revision History -->
  244. <!-- revhistory titlepage:
  245. Self-made template to add missing support on bookinfo. -->
  246. <xsl:template match="revhistory" mode="book.titlepage.verso.auto.mode">
  247. <fo:block space-before.optimum="2em"
  248. space-before.minimum="1.5em"
  249. space-before.maximum="2.5em">
  250. <xsl:apply-templates select="." mode="book.titlepage.verso.mode"/>
  251. </fo:block>
  252. </xsl:template>
  253. <!-- revhitory title properties -->
  254. <xsl:attribute-set name="revhistory.title.properties">
  255. <xsl:attribute name="text-align">center</xsl:attribute>
  256. <xsl:attribute name="font-weight">bold</xsl:attribute>
  257. </xsl:attribute-set>
  258. <!-- revhistory/revision mode titlepage.mode:
  259. Removed authorinitials | author support placing
  260. revremark | revdescription instead on that table-cell. -->
  261. <!-- The original template is in {docbook-xsl}/fo/titlepage.xsl -->
  262. <xsl:template match="revhistory/revision" mode="titlepage.mode">
  263. <xsl:variable name="revnumber" select="revnumber"/>
  264. <xsl:variable name="revdate" select="date"/>
  265. <xsl:variable name="revremark" select="revremark|revdescription"/>
  266. <fo:table-row>
  267. <fo:table-cell xsl:use-attribute-sets="revhistory.table.cell.properties">
  268. <fo:block>
  269. <xsl:if test="$revnumber">
  270. <xsl:call-template name="gentext">
  271. <xsl:with-param name="key" select="'Revision'"/>
  272. </xsl:call-template>
  273. <xsl:call-template name="gentext.space"/>
  274. <xsl:apply-templates select="$revnumber[1]" mode="titlepage.mode"/>
  275. </xsl:if>
  276. </fo:block>
  277. </fo:table-cell>
  278. <fo:table-cell xsl:use-attribute-sets="revhistory.table.cell.properties">
  279. <fo:block>
  280. <xsl:apply-templates select="$revdate[1]"/>
  281. </fo:block>
  282. </fo:table-cell>
  283. <fo:table-cell xsl:use-attribute-sets="revhistory.table.cell.properties">
  284. <fo:block>
  285. <xsl:apply-templates select="$revremark[1]"/>
  286. </fo:block>
  287. </fo:table-cell>
  288. </fo:table-row>
  289. </xsl:template>
  290. <!-- Dummy sect1 -->
  291. <!-- sect1:
  292. Self-made template to skip dummy sect1 pages generation. -->
  293. <xsl:template match="sect1">
  294. <xsl:choose>
  295. <xsl:when test="@role = 'dummy'"/>
  296. <xsl:otherwise>
  297. <xsl:apply-imports/>
  298. </xsl:otherwise>
  299. </xsl:choose>
  300. </xsl:template>
  301. <!-- sect1 mode fop1.outline:
  302. Self-made template to skip dummy sect1 bookmarks generation. -->
  303. <xsl:template match="sect1" mode="fop1.outline">
  304. <xsl:choose>
  305. <xsl:when test="@role = 'dummy'"/>
  306. <xsl:otherwise>
  307. <xsl:apply-imports/>
  308. </xsl:otherwise>
  309. </xsl:choose>
  310. </xsl:template>
  311. <!-- toc.line:
  312. For dummy sect1 output only the title. -->
  313. <!-- The original template is in {docbook-xsl}/fo/autotoc.xsl -->
  314. <xsl:template name="toc.line">
  315. <xsl:param name="toc-context" select="NOTANODE"/>
  316. <xsl:variable name="id">
  317. <xsl:call-template name="object.id"/>
  318. </xsl:variable>
  319. <xsl:variable name="label">
  320. <xsl:apply-templates select="." mode="label.markup"/>
  321. </xsl:variable>
  322. <xsl:choose>
  323. <xsl:when test="@role = 'dummy'">
  324. <fo:block text-align="left">
  325. <xsl:apply-templates select="." mode="titleabbrev.markup"/>
  326. </fo:block>
  327. </xsl:when>
  328. <xsl:otherwise>
  329. <fo:block xsl:use-attribute-sets="toc.line.properties">
  330. <fo:inline keep-with-next.within-line="always">
  331. <fo:basic-link internal-destination="{$id}">
  332. <xsl:if test="$label != ''">
  333. <xsl:copy-of select="$label"/>
  334. <xsl:value-of select="$autotoc.label.separator"/>
  335. </xsl:if>
  336. <xsl:apply-templates select="." mode="titleabbrev.markup"/>
  337. </fo:basic-link>
  338. </fo:inline>
  339. <fo:inline keep-together.within-line="always">
  340. <xsl:text> </xsl:text>
  341. <fo:leader leader-pattern="dots"
  342. leader-pattern-width="3pt"
  343. leader-alignment="reference-area"
  344. keep-with-next.within-line="always"/>
  345. <xsl:text> </xsl:text>
  346. <fo:basic-link internal-destination="{$id}">
  347. <fo:page-number-citation ref-id="{$id}"/>
  348. </fo:basic-link>
  349. </fo:inline>
  350. </fo:block>
  351. </xsl:otherwise>
  352. </xsl:choose>
  353. </xsl:template>
  354. </xsl:stylesheet>