block.xsl 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. <?xml version='1.0'?>
  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. <!-- ********************************************************************
  6. $Id$
  7. ********************************************************************
  8. This file is part of the XSL DocBook Stylesheet distribution.
  9. See ../README or http://docbook.sf.net/release/xsl/current/ for
  10. copyright and other information.
  11. ******************************************************************** -->
  12. <!-- ==================================================================== -->
  13. <!-- What should we do about styling blockinfo? -->
  14. <xsl:template match="blockinfo|info">
  15. <!-- suppress -->
  16. </xsl:template>
  17. <!-- ==================================================================== -->
  18. <xsl:template name="block.object">
  19. <fo:block>
  20. <xsl:call-template name="anchor"/>
  21. <xsl:apply-templates/>
  22. </fo:block>
  23. </xsl:template>
  24. <!-- ==================================================================== -->
  25. <xsl:template match="para">
  26. <fo:block xsl:use-attribute-sets="normal.para.spacing">
  27. <xsl:call-template name="anchor"/>
  28. <xsl:apply-templates/>
  29. </fo:block>
  30. </xsl:template>
  31. <xsl:template match="simpara">
  32. <fo:block xsl:use-attribute-sets="normal.para.spacing">
  33. <xsl:call-template name="anchor"/>
  34. <xsl:apply-templates/>
  35. </fo:block>
  36. </xsl:template>
  37. <xsl:template match="formalpara">
  38. <fo:block xsl:use-attribute-sets="normal.para.spacing">
  39. <xsl:call-template name="anchor"/>
  40. <xsl:apply-templates/>
  41. </fo:block>
  42. </xsl:template>
  43. <!-- Only use title from info -->
  44. <xsl:template match="formalpara/info">
  45. <xsl:apply-templates select="title"/>
  46. </xsl:template>
  47. <xsl:template match="formalpara/title|formalpara/info/title">
  48. <xsl:variable name="titleStr">
  49. <xsl:apply-templates/>
  50. </xsl:variable>
  51. <xsl:variable name="lastChar">
  52. <xsl:if test="$titleStr != ''">
  53. <xsl:value-of select="substring($titleStr,string-length($titleStr),1)"/>
  54. </xsl:if>
  55. </xsl:variable>
  56. <fo:inline font-weight="bold"
  57. keep-with-next.within-line="always"
  58. padding-end="1em">
  59. <xsl:copy-of select="$titleStr"/>
  60. <xsl:if test="$lastChar != ''
  61. and not(contains($runinhead.title.end.punct, $lastChar))">
  62. <xsl:value-of select="$runinhead.default.title.end.punct"/>
  63. </xsl:if>
  64. <xsl:text>&#160;</xsl:text>
  65. </fo:inline>
  66. </xsl:template>
  67. <xsl:template match="formalpara/para">
  68. <xsl:apply-templates/>
  69. </xsl:template>
  70. <!-- ==================================================================== -->
  71. <xsl:template match="blockquote">
  72. <fo:block xsl:use-attribute-sets="blockquote.properties">
  73. <xsl:call-template name="anchor"/>
  74. <fo:block>
  75. <xsl:if test="title|info/title">
  76. <fo:block xsl:use-attribute-sets="formal.title.properties">
  77. <xsl:apply-templates select="." mode="object.title.markup"/>
  78. </fo:block>
  79. </xsl:if>
  80. <xsl:apply-templates select="*[local-name(.) != 'title'
  81. and local-name(.) != 'attribution']"/>
  82. </fo:block>
  83. <xsl:if test="attribution">
  84. <fo:block text-align="right">
  85. <!-- mdash -->
  86. <xsl:text>&#x2014;</xsl:text>
  87. <xsl:apply-templates select="attribution"/>
  88. </fo:block>
  89. </xsl:if>
  90. </fo:block>
  91. </xsl:template>
  92. <xsl:template match="epigraph">
  93. <fo:block>
  94. <xsl:call-template name="anchor"/>
  95. <xsl:apply-templates select="para|simpara|formalpara|literallayout"/>
  96. <xsl:if test="attribution">
  97. <fo:inline>
  98. <xsl:text>--</xsl:text>
  99. <xsl:apply-templates select="attribution"/>
  100. </fo:inline>
  101. </xsl:if>
  102. </fo:block>
  103. </xsl:template>
  104. <xsl:template match="attribution">
  105. <fo:inline><xsl:apply-templates/></fo:inline>
  106. </xsl:template>
  107. <!-- ==================================================================== -->
  108. <xsl:template name="floater">
  109. <xsl:param name="position" select="'none'"/>
  110. <xsl:param name="clear" select="'both'"/>
  111. <xsl:param name="width"/>
  112. <xsl:param name="content"/>
  113. <xsl:param name="start.indent">0pt</xsl:param>
  114. <xsl:param name="end.indent">0pt</xsl:param>
  115. <xsl:choose>
  116. <xsl:when test="not($fop.extensions = 0)">
  117. <!-- fop 0.20.5 does not support floats -->
  118. <xsl:copy-of select="$content"/>
  119. </xsl:when>
  120. <xsl:when test="$position = 'none'">
  121. <xsl:copy-of select="$content"/>
  122. </xsl:when>
  123. <xsl:when test="$position = 'before'">
  124. <fo:float float="before">
  125. <xsl:copy-of select="$content"/>
  126. </fo:float>
  127. </xsl:when>
  128. <xsl:when test="$position = 'left' or
  129. $position = 'start' or
  130. $position = 'right' or
  131. $position = 'end' or
  132. $position = 'inside' or
  133. $position = 'outside'">
  134. <xsl:variable name="float">
  135. <fo:float float="{$position}"
  136. clear="{$clear}">
  137. <fo:block-container
  138. start-indent="{$start.indent}"
  139. end-indent="{$end.indent}">
  140. <xsl:if test="$width != ''">
  141. <xsl:attribute name="inline-progression-dimension">
  142. <xsl:value-of select="$width"/>
  143. </xsl:attribute>
  144. </xsl:if>
  145. <fo:block>
  146. <xsl:copy-of select="$content"/>
  147. </fo:block>
  148. </fo:block-container>
  149. </fo:float>
  150. </xsl:variable>
  151. <xsl:choose>
  152. <xsl:when test="$axf.extensions != 0 and self::sidebar">
  153. <fo:block xsl:use-attribute-sets="normal.para.spacing"
  154. space-after="0pt"
  155. space-after.precedence="force"
  156. start-indent="0pt" end-indent="0pt">
  157. <xsl:copy-of select="$float"/>
  158. </fo:block>
  159. </xsl:when>
  160. <xsl:when test="$axf.extensions != 0 and
  161. ($position = 'left' or $position = 'start')">
  162. <fo:float float="{$position}"
  163. clear="{$clear}">
  164. <fo:block-container
  165. inline-progression-dimension=".001mm"
  166. end-indent="{$start.indent} + {$width} + {$end.indent}">
  167. <xsl:attribute name="start-indent">
  168. <xsl:choose>
  169. <xsl:when test="ancestor::para">
  170. <!-- Special case for handling inline floats
  171. in Antenna House-->
  172. <xsl:value-of select="concat('-', $body.start.indent)"/>
  173. </xsl:when>
  174. <xsl:otherwise>0pt</xsl:otherwise>
  175. </xsl:choose>
  176. </xsl:attribute>
  177. <fo:block start-indent="{$start.indent}"
  178. end-indent="-{$start.indent} - {$width}">
  179. <xsl:copy-of select="$content"/>
  180. </fo:block>
  181. </fo:block-container>
  182. </fo:float>
  183. </xsl:when>
  184. <xsl:when test="$axf.extensions != 0 and
  185. ($position = 'right' or $position = 'end')">
  186. <!-- Special case for handling inline floats in Antenna House-->
  187. <fo:float float="{$position}"
  188. clear="{$clear}">
  189. <fo:block-container
  190. inline-progression-dimension=".001mm"
  191. end-indent="-{$body.end.indent}"
  192. start-indent="{$start.indent} + {$width} + {$end.indent}">
  193. <fo:block end-indent="{$end.indent}"
  194. start-indent="-{$end.indent} - {$width}">
  195. <xsl:copy-of select="$content"/>
  196. </fo:block>
  197. </fo:block-container>
  198. </fo:float>
  199. </xsl:when>
  200. <xsl:when test="$xep.extensions != 0 and self::sidebar">
  201. <!-- float needs some space above to line up with following para -->
  202. <fo:block xsl:use-attribute-sets="normal.para.spacing">
  203. <xsl:copy-of select="$float"/>
  204. </fo:block>
  205. </xsl:when>
  206. <xsl:when test="$xep.extensions != 0">
  207. <xsl:copy-of select="$float"/>
  208. </xsl:when>
  209. <xsl:otherwise>
  210. <xsl:copy-of select="$float"/>
  211. </xsl:otherwise>
  212. </xsl:choose>
  213. </xsl:when>
  214. <xsl:otherwise>
  215. <xsl:copy-of select="$content"/>
  216. </xsl:otherwise>
  217. </xsl:choose>
  218. </xsl:template>
  219. <xsl:template match="sidebar" name="sidebar">
  220. <!-- Also does margin notes -->
  221. <xsl:variable name="pi-type">
  222. <xsl:call-template name="pi.dbfo_float-type"/>
  223. </xsl:variable>
  224. <xsl:variable name="id">
  225. <xsl:call-template name="object.id"/>
  226. </xsl:variable>
  227. <xsl:choose>
  228. <xsl:when test="$pi-type = 'margin.note'">
  229. <xsl:call-template name="margin.note"/>
  230. </xsl:when>
  231. <xsl:otherwise>
  232. <xsl:variable name="content">
  233. <fo:block xsl:use-attribute-sets="sidebar.properties"
  234. id="{$id}">
  235. <xsl:call-template name="sidebar.titlepage"/>
  236. <xsl:apply-templates select="node()[not(self::title) and
  237. not(self::info) and
  238. not(self::sidebarinfo)]"/>
  239. </fo:block>
  240. </xsl:variable>
  241. <xsl:variable name="pi-width">
  242. <xsl:call-template name="pi.dbfo_sidebar-width"/>
  243. </xsl:variable>
  244. <xsl:variable name="position">
  245. <xsl:choose>
  246. <xsl:when test="$pi-type != ''">
  247. <xsl:value-of select="$pi-type"/>
  248. </xsl:when>
  249. <xsl:otherwise>
  250. <xsl:value-of select="$sidebar.float.type"/>
  251. </xsl:otherwise>
  252. </xsl:choose>
  253. </xsl:variable>
  254. <xsl:call-template name="floater">
  255. <xsl:with-param name="content" select="$content"/>
  256. <xsl:with-param name="position" select="$position"/>
  257. <xsl:with-param name="width">
  258. <xsl:choose>
  259. <xsl:when test="$pi-width != ''">
  260. <xsl:value-of select="$pi-width"/>
  261. </xsl:when>
  262. <xsl:otherwise>
  263. <xsl:value-of select="$sidebar.float.width"/>
  264. </xsl:otherwise>
  265. </xsl:choose>
  266. </xsl:with-param>
  267. <xsl:with-param name="start.indent">
  268. <xsl:choose>
  269. <xsl:when test="$position = 'start' or
  270. $position = 'left'">0pt</xsl:when>
  271. <xsl:when test="$position = 'end' or
  272. $position = 'right'">0.5em</xsl:when>
  273. <xsl:otherwise>0pt</xsl:otherwise>
  274. </xsl:choose>
  275. </xsl:with-param>
  276. <xsl:with-param name="end.indent">
  277. <xsl:choose>
  278. <xsl:when test="$position = 'start' or
  279. $position = 'left'">0.5em</xsl:when>
  280. <xsl:when test="$position = 'end' or
  281. $position = 'right'">0pt</xsl:when>
  282. <xsl:otherwise>0pt</xsl:otherwise>
  283. </xsl:choose>
  284. </xsl:with-param>
  285. </xsl:call-template>
  286. </xsl:otherwise>
  287. </xsl:choose>
  288. </xsl:template>
  289. <xsl:template match="sidebar/title|sidebarinfo|sidebar/info"/>
  290. <xsl:template match="sidebar/title|sidebarinfo/title|sidebar/info/title"
  291. mode="titlepage.mode" priority="1">
  292. <fo:block xsl:use-attribute-sets="sidebar.title.properties">
  293. <xsl:apply-templates/>
  294. </fo:block>
  295. </xsl:template>
  296. <xsl:template name="margin.note">
  297. <xsl:param name="content">
  298. <fo:block xsl:use-attribute-sets="margin.note.properties">
  299. <xsl:if test="./title">
  300. <fo:block xsl:use-attribute-sets="margin.note.title.properties">
  301. <xsl:apply-templates select="./title" mode="margin.note.title.mode"/>
  302. </fo:block>
  303. </xsl:if>
  304. <xsl:apply-templates/>
  305. </fo:block>
  306. </xsl:param>
  307. <xsl:variable name="pi-width">
  308. <xsl:call-template name="pi.dbfo_sidebar-width"/>
  309. </xsl:variable>
  310. <xsl:variable name="position" select="$margin.note.float.type"/>
  311. <xsl:call-template name="floater">
  312. <xsl:with-param name="content" select="$content"/>
  313. <xsl:with-param name="position" select="$position"/>
  314. <xsl:with-param name="width" >
  315. <xsl:choose>
  316. <xsl:when test="$pi-width != ''">
  317. <xsl:value-of select="$pi-width"/>
  318. </xsl:when>
  319. <xsl:otherwise>
  320. <xsl:value-of select="$margin.note.width"/>
  321. </xsl:otherwise>
  322. </xsl:choose>
  323. </xsl:with-param>
  324. <xsl:with-param name="start.indent">
  325. <xsl:choose>
  326. <xsl:when test="$position = 'start' or
  327. $position = 'left'">0pt</xsl:when>
  328. <xsl:when test="$position = 'end' or
  329. $position = 'right'">0.5em</xsl:when>
  330. <xsl:otherwise>0pt</xsl:otherwise>
  331. </xsl:choose>
  332. </xsl:with-param>
  333. <xsl:with-param name="end.indent">
  334. <xsl:choose>
  335. <xsl:when test="$position = 'start' or
  336. $position = 'left'">0.5em</xsl:when>
  337. <xsl:when test="$position = 'end' or
  338. $position = 'right'">0pt</xsl:when>
  339. <xsl:otherwise>0pt</xsl:otherwise>
  340. </xsl:choose>
  341. </xsl:with-param>
  342. </xsl:call-template>
  343. </xsl:template>
  344. <xsl:template match="sidebar/title" mode="margin.note.title.mode">
  345. <xsl:apply-templates/>
  346. </xsl:template>
  347. <!-- ==================================================================== -->
  348. <xsl:template match="abstract">
  349. <fo:block xsl:use-attribute-sets="abstract.properties">
  350. <xsl:call-template name="anchor"/>
  351. <xsl:apply-templates/>
  352. </fo:block>
  353. </xsl:template>
  354. <xsl:template match="abstract/title|abstract/info/title">
  355. <fo:block xsl:use-attribute-sets="abstract.title.properties">
  356. <xsl:apply-templates/>
  357. </fo:block>
  358. </xsl:template>
  359. <!-- ==================================================================== -->
  360. <xsl:template match="msgset">
  361. <xsl:apply-templates/>
  362. </xsl:template>
  363. <xsl:template match="msgentry">
  364. <xsl:call-template name="block.object"/>
  365. </xsl:template>
  366. <xsl:template match="simplemsgentry">
  367. <xsl:call-template name="block.object"/>
  368. </xsl:template>
  369. <xsl:template match="msg">
  370. <xsl:call-template name="block.object"/>
  371. </xsl:template>
  372. <xsl:template match="msgmain">
  373. <xsl:apply-templates/>
  374. </xsl:template>
  375. <xsl:template match="msgsub">
  376. <xsl:apply-templates/>
  377. </xsl:template>
  378. <xsl:template match="msgrel">
  379. <xsl:apply-templates/>
  380. </xsl:template>
  381. <xsl:template match="msgtext">
  382. <xsl:apply-templates/>
  383. </xsl:template>
  384. <xsl:template match="msginfo">
  385. <xsl:call-template name="block.object"/>
  386. </xsl:template>
  387. <xsl:template match="msglevel">
  388. <fo:block>
  389. <fo:inline font-weight="bold"
  390. keep-with-next.within-line="always">
  391. <xsl:call-template name="gentext.template">
  392. <xsl:with-param name="context" select="'msgset'"/>
  393. <xsl:with-param name="name" select="'MsgLevel'"/>
  394. </xsl:call-template>
  395. </fo:inline>
  396. <xsl:apply-templates/>
  397. </fo:block>
  398. </xsl:template>
  399. <xsl:template match="msgorig">
  400. <fo:block>
  401. <fo:inline font-weight="bold"
  402. keep-with-next.within-line="always">
  403. <xsl:call-template name="gentext.template">
  404. <xsl:with-param name="context" select="'msgset'"/>
  405. <xsl:with-param name="name" select="'MsgOrig'"/>
  406. </xsl:call-template>
  407. </fo:inline>
  408. <xsl:apply-templates/>
  409. </fo:block>
  410. </xsl:template>
  411. <xsl:template match="msgaud">
  412. <fo:block>
  413. <fo:inline font-weight="bold"
  414. keep-with-next.within-line="always">
  415. <xsl:call-template name="gentext.template">
  416. <xsl:with-param name="context" select="'msgset'"/>
  417. <xsl:with-param name="name" select="'MsgAud'"/>
  418. </xsl:call-template>
  419. </fo:inline>
  420. <xsl:apply-templates/>
  421. </fo:block>
  422. </xsl:template>
  423. <xsl:template match="msgexplan">
  424. <xsl:call-template name="block.object"/>
  425. </xsl:template>
  426. <xsl:template match="msgexplan/title">
  427. <fo:block font-weight="bold"
  428. keep-with-next.within-column="always"
  429. hyphenate="false">
  430. <xsl:apply-templates/>
  431. </fo:block>
  432. </xsl:template>
  433. <!-- ==================================================================== -->
  434. <!-- For better or worse, revhistory is allowed in content... -->
  435. <xsl:template match="revhistory">
  436. <fo:table table-layout="fixed" xsl:use-attribute-sets="revhistory.table.properties">
  437. <xsl:call-template name="anchor"/>
  438. <fo:table-column column-number="1" column-width="proportional-column-width(1)"/>
  439. <fo:table-column column-number="2" column-width="proportional-column-width(1)"/>
  440. <fo:table-column column-number="3" column-width="proportional-column-width(1)"/>
  441. <fo:table-body start-indent="0pt" end-indent="0pt">
  442. <fo:table-row>
  443. <fo:table-cell number-columns-spanned="3" xsl:use-attribute-sets="revhistory.table.cell.properties">
  444. <fo:block xsl:use-attribute-sets="revhistory.title.properties">
  445. <xsl:call-template name="gentext">
  446. <xsl:with-param name="key" select="'RevHistory'"/>
  447. </xsl:call-template>
  448. </fo:block>
  449. </fo:table-cell>
  450. </fo:table-row>
  451. <xsl:apply-templates/>
  452. </fo:table-body>
  453. </fo:table>
  454. </xsl:template>
  455. <xsl:template match="revhistory/revision">
  456. <xsl:variable name="revnumber" select="revnumber"/>
  457. <xsl:variable name="revdate" select="date"/>
  458. <xsl:variable name="revauthor" select="authorinitials|author"/>
  459. <xsl:variable name="revremark" select="revremark|revdescription"/>
  460. <fo:table-row>
  461. <fo:table-cell xsl:use-attribute-sets="revhistory.table.cell.properties">
  462. <fo:block>
  463. <xsl:call-template name="anchor"/>
  464. <xsl:if test="$revnumber">
  465. <xsl:call-template name="gentext">
  466. <xsl:with-param name="key" select="'Revision'"/>
  467. </xsl:call-template>
  468. <xsl:call-template name="gentext.space"/>
  469. <xsl:apply-templates select="$revnumber[1]"/>
  470. </xsl:if>
  471. </fo:block>
  472. </fo:table-cell>
  473. <fo:table-cell xsl:use-attribute-sets="revhistory.table.cell.properties">
  474. <fo:block>
  475. <xsl:apply-templates select="$revdate[1]"/>
  476. </fo:block>
  477. </fo:table-cell>
  478. <fo:table-cell xsl:use-attribute-sets="revhistory.table.cell.properties">
  479. <fo:block>
  480. <xsl:for-each select="$revauthor">
  481. <xsl:apply-templates select="."/>
  482. <xsl:if test="position() != last()">
  483. <xsl:text>, </xsl:text>
  484. </xsl:if>
  485. </xsl:for-each>
  486. </fo:block>
  487. </fo:table-cell>
  488. </fo:table-row>
  489. <xsl:if test="$revremark">
  490. <fo:table-row>
  491. <fo:table-cell number-columns-spanned="3" xsl:use-attribute-sets="revhistory.table.cell.properties">
  492. <fo:block>
  493. <xsl:apply-templates select="$revremark[1]"/>
  494. </fo:block>
  495. </fo:table-cell>
  496. </fo:table-row>
  497. </xsl:if>
  498. </xsl:template>
  499. <xsl:template match="revision/revnumber">
  500. <xsl:apply-templates/>
  501. </xsl:template>
  502. <xsl:template match="revision/date">
  503. <xsl:apply-templates/>
  504. </xsl:template>
  505. <xsl:template match="revision/authorinitials">
  506. <xsl:apply-templates/>
  507. </xsl:template>
  508. <xsl:template match="revision/author">
  509. <xsl:apply-templates/>
  510. </xsl:template>
  511. <xsl:template match="revision/revremark">
  512. <xsl:apply-templates/>
  513. </xsl:template>
  514. <xsl:template match="revision/revdescription">
  515. <xsl:apply-templates/>
  516. </xsl:template>
  517. <!-- ==================================================================== -->
  518. <xsl:template match="ackno">
  519. <fo:block xsl:use-attribute-sets="normal.para.spacing">
  520. <xsl:call-template name="anchor"/>
  521. <xsl:apply-templates/>
  522. </fo:block>
  523. </xsl:template>
  524. <!-- ==================================================================== -->
  525. <xsl:template match="highlights">
  526. <xsl:call-template name="block.object"/>
  527. </xsl:template>
  528. <!-- ==================================================================== -->
  529. </xsl:stylesheet>