lfs-mixed.xsl 14 KB

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