lfs-mixed.xsl 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  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:when test="$book-type = 'blfs'">auto</xsl:when>
  94. <xsl:otherwise>always</xsl:otherwise>
  95. </xsl:choose>
  96. </xsl:attribute>
  97. <xsl:apply-imports/>
  98. </fo:block>
  99. </xsl:template>
  100. <!-- literal:
  101. Be sure that literal will use allways normal font weight. -->
  102. <!-- The original template is in {docbook-xsl}/fo/inline.xsl -->
  103. <xsl:template match="literal">
  104. <fo:inline font-weight="normal">
  105. <xsl:call-template name="inline.monoseq"/>
  106. </fo:inline>
  107. </xsl:template>
  108. <!-- inline.monoseq:
  109. Added hyphenate-url support to classname, exceptionname, interfacename,
  110. methodname, computeroutput, constant, envar, filename, function, code,
  111. literal, option, promt, systemitem, varname, sgmltag, tag, and uri -->
  112. <!-- The original template is in {docbook-xsl}/fo/inline.xsl -->
  113. <xsl:template name="inline.monoseq">
  114. <xsl:param name="content">
  115. <xsl:call-template name="simple.xlink">
  116. <xsl:with-param name="content">
  117. <xsl:choose>
  118. <xsl:when test="ancestor::para and not(ancestor::screen)
  119. and not(descendant::ulink)">
  120. <xsl:call-template name="hyphenate-url">
  121. <xsl:with-param name="url">
  122. <xsl:apply-templates/>
  123. </xsl:with-param>
  124. </xsl:call-template>
  125. </xsl:when>
  126. <xsl:otherwise>
  127. <xsl:apply-templates/>
  128. </xsl:otherwise>
  129. </xsl:choose>
  130. </xsl:with-param>
  131. </xsl:call-template>
  132. </xsl:param>
  133. <fo:inline xsl:use-attribute-sets="monospace.properties">
  134. <xsl:if test="@dir">
  135. <xsl:attribute name="direction">
  136. <xsl:choose>
  137. <xsl:when test="@dir = 'ltr' or @dir = 'lro'">ltr</xsl:when>
  138. <xsl:otherwise>rtl</xsl:otherwise>
  139. </xsl:choose>
  140. </xsl:attribute>
  141. </xsl:if>
  142. <xsl:copy-of select="$content"/>
  143. </fo:inline>
  144. </xsl:template>
  145. <!-- inline.italicmonoseq:
  146. Added hyphenate-url support to parameter, replaceable, structfield,
  147. function/parameter, and function/replaceable -->
  148. <!-- The original template is in {docbook-xsl}/fo/inline.xsl -->
  149. <xsl:template name="inline.italicmonoseq">
  150. <xsl:param name="content">
  151. <xsl:call-template name="simple.xlink">
  152. <xsl:with-param name="content">
  153. <xsl:choose>
  154. <xsl:when test="ancestor::para and not(ancestor::screen)
  155. and not(descendant::ulink)">
  156. <xsl:call-template name="hyphenate-url">
  157. <xsl:with-param name="url">
  158. <xsl:apply-templates/>
  159. </xsl:with-param>
  160. </xsl:call-template>
  161. </xsl:when>
  162. <xsl:otherwise>
  163. <xsl:apply-templates/>
  164. </xsl:otherwise>
  165. </xsl:choose>
  166. </xsl:with-param>
  167. </xsl:call-template>
  168. </xsl:param>
  169. <fo:inline font-style="italic" xsl:use-attribute-sets="monospace.properties">
  170. <xsl:call-template name="anchor"/>
  171. <xsl:if test="@dir">
  172. <xsl:attribute name="direction">
  173. <xsl:choose>
  174. <xsl:when test="@dir = 'ltr' or @dir = 'lro'">ltr</xsl:when>
  175. <xsl:otherwise>rtl</xsl:otherwise>
  176. </xsl:choose>
  177. </xsl:attribute>
  178. </xsl:if>
  179. <xsl:copy-of select="$content"/>
  180. </fo:inline>
  181. </xsl:template>
  182. <!-- Show external URLs in italic font -->
  183. <xsl:attribute-set name="xref.properties">
  184. <xsl:attribute name="font-style">
  185. <xsl:choose>
  186. <xsl:when test="self::ulink">italic</xsl:when>
  187. <xsl:otherwise>inherit</xsl:otherwise>
  188. </xsl:choose>
  189. </xsl:attribute>
  190. </xsl:attribute-set>
  191. <!-- Lists -->
  192. <!-- What spacing do you want before and after lists? -->
  193. <xsl:attribute-set name="list.block.spacing">
  194. <xsl:attribute name="space-before.optimum">0.6em</xsl:attribute>
  195. <xsl:attribute name="space-before.minimum">0.4em</xsl:attribute>
  196. <xsl:attribute name="space-before.maximum">0.8em</xsl:attribute>
  197. <xsl:attribute name="space-after.optimum">0.6em</xsl:attribute>
  198. <xsl:attribute name="space-after.minimum">0.4em</xsl:attribute>
  199. <xsl:attribute name="space-after.maximum">0.8em</xsl:attribute>
  200. </xsl:attribute-set>
  201. <!-- What spacing do you want between list items? -->
  202. <xsl:attribute-set name="list.item.spacing">
  203. <xsl:attribute name="space-before.optimum">0.4em</xsl:attribute>
  204. <xsl:attribute name="space-before.minimum">0.2em</xsl:attribute>
  205. <xsl:attribute name="space-before.maximum">0.6em</xsl:attribute>
  206. </xsl:attribute-set>
  207. <!-- Properties that apply to each list-block generated by itemizedlist. -->
  208. <xsl:attribute-set name="itemizedlist.properties"
  209. use-attribute-sets="list.block.properties">
  210. <xsl:attribute name="text-align">left</xsl:attribute>
  211. </xsl:attribute-set>
  212. <!-- Format variablelists lists as blocks? 1 = yes, 0 = no
  213. Default variablelist format. We override it when necesary
  214. using the list-presentation processing instruction. -->
  215. <xsl:param name="variablelist.as.blocks" select="1"/>
  216. <!-- Specifies the longest term in variablelists.
  217. Used when list-presentation = list -->
  218. <xsl:param name="variablelist.max.termlength">35</xsl:param>
  219. <!-- varlistentry mode block:
  220. Addibg a bullet, left alignament, and @kepp-*.* attributes
  221. for packages and paches list. -->
  222. <!-- The original template is in {docbook-xsl}/fo/list.xsl -->
  223. <xsl:template match="varlistentry" mode="vl.as.blocks">
  224. <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
  225. <xsl:choose>
  226. <xsl:when test="ancestor::variablelist/@role = 'materials'">
  227. <fo:block id="{$id}" xsl:use-attribute-sets="list.item.spacing"
  228. keep-together.within-column="always" font-weight="bold"
  229. keep-with-next.within-column="always" text-align="left">
  230. <xsl:text>&#x2022; </xsl:text>
  231. <xsl:apply-templates select="term"/>
  232. </fo:block>
  233. <fo:block text-align="left"
  234. keep-together.within-column="always"
  235. keep-with-previous.within-column="always">
  236. <xsl:apply-templates select="listitem"/>
  237. </fo:block>
  238. </xsl:when>
  239. <xsl:otherwise>
  240. <fo:block id="{$id}" xsl:use-attribute-sets="list.item.spacing"
  241. keep-together.within-column="always"
  242. keep-with-next.within-column="always" margin-left="1em">
  243. <xsl:apply-templates select="term"/>
  244. </fo:block>
  245. <fo:block margin-left="2em">
  246. <xsl:apply-templates select="listitem"/>
  247. </fo:block>
  248. </xsl:otherwise>
  249. </xsl:choose>
  250. </xsl:template>
  251. <!-- segmentedlist:
  252. Making it an actual FO list to can indent items.
  253. Adjust vertical space. -->
  254. <!-- The original template is in {docbook-xsl}/fo/list.xsl -->
  255. <xsl:template match="segmentedlist">
  256. <xsl:variable name="id">
  257. <xsl:call-template name="object.id"/>
  258. </xsl:variable>
  259. <fo:list-block id="{$id}" provisional-distance-between-starts="12em"
  260. provisional-label-separation="1em"
  261. keep-together.within-column="always">
  262. <xsl:choose>
  263. <xsl:when test="ancestor::appendix[@id='appendixc']">
  264. <xsl:attribute name="space-before.optimum">0.2em</xsl:attribute>
  265. <xsl:attribute name="space-before.minimum">0em</xsl:attribute>
  266. <xsl:attribute name="space-before.maximum">0.4em</xsl:attribute>
  267. <xsl:attribute name="space-after.optimum">0.2em</xsl:attribute>
  268. <xsl:attribute name="space-after.minimum">0em</xsl:attribute>
  269. <xsl:attribute name="space-after.maximum">0.4em</xsl:attribute>
  270. <xsl:attribute name="keep-with-previous.within-column">always</xsl:attribute>
  271. </xsl:when>
  272. <xsl:otherwise>
  273. <xsl:attribute name="space-before.optimum">0.4em</xsl:attribute>
  274. <xsl:attribute name="space-before.minimum">0.2em</xsl:attribute>
  275. <xsl:attribute name="space-before.maximum">0.6em</xsl:attribute>
  276. <xsl:attribute name="space-after.optimum">0.4em</xsl:attribute>
  277. <xsl:attribute name="space-after.minimum">0.2em</xsl:attribute>
  278. <xsl:attribute name="space-after.maximum">0.6em</xsl:attribute>
  279. </xsl:otherwise>
  280. </xsl:choose>
  281. <xsl:apply-templates select="seglistitem/seg"/>
  282. </fo:list-block>
  283. </xsl:template>
  284. <!-- seg:
  285. Self-made template based on the original seg template
  286. found in {docbook-xsl}/fo/list.xsl
  287. Making segmentedlist an actual FO list to can indent items. -->
  288. <xsl:template match="seglistitem/seg">
  289. <xsl:variable name="id">
  290. <xsl:call-template name="object.id"/>
  291. </xsl:variable>
  292. <xsl:variable name="segnum" select="count(preceding-sibling::seg)+1"/>
  293. <xsl:variable name="seglist" select="ancestor::segmentedlist"/>
  294. <xsl:variable name="segtitles" select="$seglist/segtitle"/>
  295. <fo:list-item xsl:use-attribute-sets="compact.list.item.spacing">
  296. <fo:list-item-label end-indent="label-end()" text-align="start">
  297. <fo:block>
  298. <fo:inline font-weight="bold">
  299. <xsl:apply-templates select="$segtitles[$segnum=position()]"
  300. mode="segtitle-in-seg"/>
  301. <xsl:text>:</xsl:text>
  302. </fo:inline>
  303. </fo:block>
  304. </fo:list-item-label>
  305. <fo:list-item-body start-indent="body-start()">
  306. <fo:block id="{$id}">
  307. <xsl:apply-templates/>
  308. </fo:block>
  309. </fo:list-item-body>
  310. </fo:list-item>
  311. </xsl:template>
  312. <!-- simplelist:
  313. Self-made template. Wrap it into a fo:block and process member childs.
  314. If @type is specified, the original templates will be used.
  315. NOTE: when using type='horiz' or type='vert', FOP-0.93 will complaints
  316. about not supported table-layout="auto" -->
  317. <xsl:template match="simplelist">
  318. <fo:block xsl:use-attribute-sets="simplelist.properties">
  319. <xsl:apply-templates mode="condensed"/>
  320. </fo:block>
  321. </xsl:template>
  322. <!-- member:
  323. Self-made template to wrap it into a fo:block using customized
  324. properties. -->
  325. <xsl:template match="member" mode="condensed">
  326. <fo:block xsl:use-attribute-sets="simplelist.properties">
  327. <xsl:call-template name="simple.xlink">
  328. <xsl:with-param name="content">
  329. <xsl:apply-templates/>
  330. </xsl:with-param>
  331. </xsl:call-template>
  332. </fo:block>
  333. </xsl:template>
  334. <!-- Properties associated with our simplelist format. -->
  335. <xsl:attribute-set name="simplelist.properties">
  336. <xsl:attribute name="keep-with-previous.within-column">always</xsl:attribute>
  337. <xsl:attribute name="space-before.optimum">0em</xsl:attribute>
  338. <xsl:attribute name="space-before.minimum">0em</xsl:attribute>
  339. <xsl:attribute name="space-before.maximum">0.2em</xsl:attribute>
  340. </xsl:attribute-set>
  341. <!-- Revision History -->
  342. <!-- revhistory titlepage:
  343. Self-made template to add missing support on bookinfo. -->
  344. <xsl:template match="revhistory" mode="book.titlepage.verso.auto.mode">
  345. <fo:block space-before.optimum="2em"
  346. space-before.minimum="1.5em"
  347. space-before.maximum="2.5em">
  348. <xsl:apply-templates select="." mode="book.titlepage.verso.mode"/>
  349. </fo:block>
  350. </xsl:template>
  351. <!-- revhitory title properties -->
  352. <xsl:attribute-set name="revhistory.title.properties">
  353. <xsl:attribute name="text-align">center</xsl:attribute>
  354. <xsl:attribute name="font-weight">bold</xsl:attribute>
  355. </xsl:attribute-set>
  356. <!-- revhistory/revision mode titlepage.mode:
  357. Removed authorinitials | author support placing
  358. revremark | revdescription instead on that table-cell. -->
  359. <!-- The original template is in {docbook-xsl}/fo/titlepage.xsl -->
  360. <xsl:template match="revhistory/revision" mode="titlepage.mode">
  361. <xsl:variable name="revnumber" select="revnumber"/>
  362. <xsl:variable name="revdate" select="date"/>
  363. <xsl:variable name="revremark" select="revremark|revdescription"/>
  364. <fo:table-row>
  365. <fo:table-cell xsl:use-attribute-sets="revhistory.table.cell.properties">
  366. <fo:block>
  367. <xsl:if test="$revnumber">
  368. <xsl:call-template name="gentext">
  369. <xsl:with-param name="key" select="'Revision'"/>
  370. </xsl:call-template>
  371. <xsl:call-template name="gentext.space"/>
  372. <xsl:apply-templates select="$revnumber[1]" mode="titlepage.mode"/>
  373. </xsl:if>
  374. </fo:block>
  375. </fo:table-cell>
  376. <fo:table-cell xsl:use-attribute-sets="revhistory.table.cell.properties">
  377. <fo:block>
  378. <xsl:apply-templates select="$revdate[1]"/>
  379. </fo:block>
  380. </fo:table-cell>
  381. <fo:table-cell xsl:use-attribute-sets="revhistory.table.cell.properties">
  382. <fo:block>
  383. <xsl:apply-templates select="$revremark[1]"/>
  384. </fo:block>
  385. </fo:table-cell>
  386. </fo:table-row>
  387. </xsl:template>
  388. <!-- Dummy sect1 -->
  389. <!-- sect1:
  390. Self-made template to skip dummy sect1 pages generation. -->
  391. <xsl:template match="sect1">
  392. <xsl:choose>
  393. <xsl:when test="@role = 'dummy'"/>
  394. <xsl:otherwise>
  395. <xsl:apply-imports/>
  396. </xsl:otherwise>
  397. </xsl:choose>
  398. </xsl:template>
  399. <!-- sect1 mode fop1.outline:
  400. Self-made template to skip dummy sect1 bookmarks generation. -->
  401. <xsl:template match="sect1" mode="fop1.outline">
  402. <xsl:choose>
  403. <xsl:when test="@role = 'dummy'"/>
  404. <xsl:otherwise>
  405. <xsl:apply-imports/>
  406. </xsl:otherwise>
  407. </xsl:choose>
  408. </xsl:template>
  409. <!-- toc.line:
  410. For dummy sect1 output only the title. -->
  411. <!-- The original template is in {docbook-xsl}/fo/autotoc.xsl -->
  412. <xsl:template name="toc.line">
  413. <xsl:param name="toc-context" select="NOTANODE"/>
  414. <xsl:variable name="id">
  415. <xsl:call-template name="object.id"/>
  416. </xsl:variable>
  417. <xsl:variable name="label">
  418. <xsl:apply-templates select="." mode="label.markup"/>
  419. </xsl:variable>
  420. <xsl:choose>
  421. <xsl:when test="@role = 'dummy'">
  422. <fo:block text-align="left">
  423. <xsl:apply-templates select="." mode="titleabbrev.markup"/>
  424. </fo:block>
  425. </xsl:when>
  426. <xsl:otherwise>
  427. <fo:block xsl:use-attribute-sets="toc.line.properties">
  428. <fo:inline keep-with-next.within-line="always">
  429. <fo:basic-link internal-destination="{$id}">
  430. <xsl:if test="$label != ''">
  431. <xsl:copy-of select="$label"/>
  432. <xsl:value-of select="$autotoc.label.separator"/>
  433. </xsl:if>
  434. <xsl:apply-templates select="." mode="titleabbrev.markup"/>
  435. </fo:basic-link>
  436. </fo:inline>
  437. <fo:inline keep-together.within-line="always">
  438. <xsl:text> </xsl:text>
  439. <fo:leader leader-pattern="dots"
  440. leader-pattern-width="3pt"
  441. leader-alignment="reference-area"
  442. keep-with-next.within-line="always"/>
  443. <xsl:text> </xsl:text>
  444. <fo:basic-link internal-destination="{$id}">
  445. <fo:page-number-citation ref-id="{$id}"/>
  446. </fo:basic-link>
  447. </fo:inline>
  448. </fo:block>
  449. </xsl:otherwise>
  450. </xsl:choose>
  451. </xsl:template>
  452. </xsl:stylesheet>