lfs-mixed.xsl 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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="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(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. <!-- Revision History -->
  191. <!-- revhistory titlepage:
  192. Self-made template to add missing support on bookinfo. -->
  193. <xsl:template match="revhistory" mode="book.titlepage.verso.auto.mode">
  194. <fo:block space-before.optimum="2em"
  195. space-before.minimum="1.5em"
  196. space-before.maximum="2.5em">
  197. <xsl:apply-templates select="." mode="book.titlepage.verso.mode"/>
  198. </fo:block>
  199. </xsl:template>
  200. <!-- revhitory title properties -->
  201. <xsl:attribute-set name="revhistory.title.properties">
  202. <xsl:attribute name="text-align">center</xsl:attribute>
  203. <xsl:attribute name="font-weight">bold</xsl:attribute>
  204. </xsl:attribute-set>
  205. <!-- revhistory/revision mode titlepage.mode:
  206. Removed authorinitials | author support placing
  207. revremark | revdescription instead on that table-cell. -->
  208. <!-- The original template is in {docbook-xsl}/fo/titlepage.xsl -->
  209. <xsl:template match="revhistory/revision" mode="titlepage.mode">
  210. <xsl:variable name="revnumber" select="revnumber"/>
  211. <xsl:variable name="revdate" select="date"/>
  212. <xsl:variable name="revremark" select="revremark|revdescription"/>
  213. <fo:table-row>
  214. <fo:table-cell xsl:use-attribute-sets="revhistory.table.cell.properties">
  215. <fo:block>
  216. <xsl:if test="$revnumber">
  217. <xsl:call-template name="gentext">
  218. <xsl:with-param name="key" select="'Revision'"/>
  219. </xsl:call-template>
  220. <xsl:call-template name="gentext.space"/>
  221. <xsl:apply-templates select="$revnumber[1]" mode="titlepage.mode"/>
  222. </xsl:if>
  223. </fo:block>
  224. </fo:table-cell>
  225. <fo:table-cell xsl:use-attribute-sets="revhistory.table.cell.properties">
  226. <fo:block>
  227. <xsl:apply-templates select="$revdate[1]"/>
  228. </fo:block>
  229. </fo:table-cell>
  230. <fo:table-cell xsl:use-attribute-sets="revhistory.table.cell.properties">
  231. <fo:block>
  232. <xsl:apply-templates select="$revremark[1]"/>
  233. </fo:block>
  234. </fo:table-cell>
  235. </fo:table-row>
  236. </xsl:template>
  237. <!-- Dummy sect1 -->
  238. <!-- sect1:
  239. Self-made template to skip dummy sect1 pages generation. -->
  240. <xsl:template match="sect1">
  241. <xsl:choose>
  242. <xsl:when test="@role = 'dummy'"/>
  243. <xsl:otherwise>
  244. <xsl:apply-imports/>
  245. </xsl:otherwise>
  246. </xsl:choose>
  247. </xsl:template>
  248. <!-- sect1 mode fop1.outline:
  249. Self-made template to skip dummy sect1 bookmarks generation. -->
  250. <xsl:template match="sect1" mode="fop1.outline">
  251. <xsl:choose>
  252. <xsl:when test="@role = 'dummy'"/>
  253. <xsl:otherwise>
  254. <xsl:apply-imports/>
  255. </xsl:otherwise>
  256. </xsl:choose>
  257. </xsl:template>
  258. <!-- toc.line:
  259. For dummy sect1 output only the title. -->
  260. <!-- The original template is in {docbook-xsl}/fo/autotoc.xsl -->
  261. <xsl:template name="toc.line">
  262. <xsl:param name="toc-context" select="NOTANODE"/>
  263. <xsl:variable name="id">
  264. <xsl:call-template name="object.id"/>
  265. </xsl:variable>
  266. <xsl:variable name="label">
  267. <xsl:apply-templates select="." mode="label.markup"/>
  268. </xsl:variable>
  269. <xsl:choose>
  270. <xsl:when test="@role = 'dummy'">
  271. <fo:block text-align="left">
  272. <xsl:apply-templates select="." mode="titleabbrev.markup"/>
  273. </fo:block>
  274. </xsl:when>
  275. <xsl:otherwise>
  276. <fo:block xsl:use-attribute-sets="toc.line.properties">
  277. <fo:inline keep-with-next.within-line="always">
  278. <fo:basic-link internal-destination="{$id}">
  279. <xsl:if test="$label != ''">
  280. <xsl:copy-of select="$label"/>
  281. <xsl:value-of select="$autotoc.label.separator"/>
  282. </xsl:if>
  283. <xsl:apply-templates select="." mode="titleabbrev.markup"/>
  284. </fo:basic-link>
  285. </fo:inline>
  286. <fo:inline keep-together.within-line="always">
  287. <xsl:text> </xsl:text>
  288. <fo:leader leader-pattern="dots"
  289. leader-pattern-width="3pt"
  290. leader-alignment="reference-area"
  291. keep-with-next.within-line="always"/>
  292. <xsl:text> </xsl:text>
  293. <fo:basic-link internal-destination="{$id}">
  294. <fo:page-number-citation ref-id="{$id}"/>
  295. </fo:basic-link>
  296. </fo:inline>
  297. </fo:block>
  298. </xsl:otherwise>
  299. </xsl:choose>
  300. </xsl:template>
  301. </xsl:stylesheet>