1
0

lfs-mixed.xsl 14 KB

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