block.xsl 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  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://nwalsh.com/docbook/xsl/ for copyright
  10. 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="dbfo-attribute">
  223. <xsl:with-param name="pis"
  224. select="processing-instruction('dbfo')"/>
  225. <xsl:with-param name="attribute" select="'float-type'"/>
  226. </xsl:call-template>
  227. </xsl:variable>
  228. <xsl:variable name="id">
  229. <xsl:call-template name="object.id"/>
  230. </xsl:variable>
  231. <xsl:choose>
  232. <xsl:when test="$pi-type = 'margin.note'">
  233. <xsl:call-template name="margin.note"/>
  234. </xsl:when>
  235. <xsl:otherwise>
  236. <xsl:variable name="content">
  237. <fo:block xsl:use-attribute-sets="sidebar.properties"
  238. id="{$id}">
  239. <xsl:call-template name="sidebar.titlepage"/>
  240. <xsl:apply-templates select="node()[not(self::title) and
  241. not(self::info) and
  242. not(self::sidebarinfo)]"/>
  243. </fo:block>
  244. </xsl:variable>
  245. <xsl:variable name="pi-width">
  246. <xsl:call-template name="dbfo-attribute">
  247. <xsl:with-param name="pis"
  248. select="processing-instruction('dbfo')"/>
  249. <xsl:with-param name="attribute" select="'sidebar-width'"/>
  250. </xsl:call-template>
  251. </xsl:variable>
  252. <xsl:variable name="position">
  253. <xsl:choose>
  254. <xsl:when test="$pi-type != ''">
  255. <xsl:value-of select="$pi-type"/>
  256. </xsl:when>
  257. <xsl:otherwise>
  258. <xsl:value-of select="$sidebar.float.type"/>
  259. </xsl:otherwise>
  260. </xsl:choose>
  261. </xsl:variable>
  262. <xsl:call-template name="floater">
  263. <xsl:with-param name="content" select="$content"/>
  264. <xsl:with-param name="position" select="$position"/>
  265. <xsl:with-param name="width">
  266. <xsl:choose>
  267. <xsl:when test="$pi-width != ''">
  268. <xsl:value-of select="$pi-width"/>
  269. </xsl:when>
  270. <xsl:otherwise>
  271. <xsl:value-of select="$sidebar.float.width"/>
  272. </xsl:otherwise>
  273. </xsl:choose>
  274. </xsl:with-param>
  275. <xsl:with-param name="start.indent">
  276. <xsl:choose>
  277. <xsl:when test="$position = 'start' or
  278. $position = 'left'">0pt</xsl:when>
  279. <xsl:when test="$position = 'end' or
  280. $position = 'right'">0.5em</xsl:when>
  281. <xsl:otherwise>0pt</xsl:otherwise>
  282. </xsl:choose>
  283. </xsl:with-param>
  284. <xsl:with-param name="end.indent">
  285. <xsl:choose>
  286. <xsl:when test="$position = 'start' or
  287. $position = 'left'">0.5em</xsl:when>
  288. <xsl:when test="$position = 'end' or
  289. $position = 'right'">0pt</xsl:when>
  290. <xsl:otherwise>0pt</xsl:otherwise>
  291. </xsl:choose>
  292. </xsl:with-param>
  293. </xsl:call-template>
  294. </xsl:otherwise>
  295. </xsl:choose>
  296. </xsl:template>
  297. <xsl:template match="sidebar/title|sidebarinfo|sidebar/info"/>
  298. <xsl:template match="sidebar/title|sidebarinfo/title|sidebar/info/title"
  299. mode="titlepage.mode" priority="1">
  300. <fo:block xsl:use-attribute-sets="sidebar.title.properties">
  301. <xsl:apply-templates/>
  302. </fo:block>
  303. </xsl:template>
  304. <xsl:template name="margin.note">
  305. <xsl:param name="content">
  306. <fo:block xsl:use-attribute-sets="margin.note.properties">
  307. <xsl:if test="./title">
  308. <fo:block xsl:use-attribute-sets="margin.note.title.properties">
  309. <xsl:apply-templates select="./title" mode="margin.note.title.mode"/>
  310. </fo:block>
  311. </xsl:if>
  312. <xsl:apply-templates/>
  313. </fo:block>
  314. </xsl:param>
  315. <xsl:variable name="pi-width">
  316. <xsl:call-template name="dbfo-attribute">
  317. <xsl:with-param name="pis"
  318. select="processing-instruction('dbfo')"/>
  319. <xsl:with-param name="attribute" select="'sidebar-width'"/>
  320. </xsl:call-template>
  321. </xsl:variable>
  322. <xsl:variable name="position" select="$margin.note.float.type"/>
  323. <xsl:call-template name="floater">
  324. <xsl:with-param name="content" select="$content"/>
  325. <xsl:with-param name="position" select="$position"/>
  326. <xsl:with-param name="width" >
  327. <xsl:choose>
  328. <xsl:when test="$pi-width != ''">
  329. <xsl:value-of select="$pi-width"/>
  330. </xsl:when>
  331. <xsl:otherwise>
  332. <xsl:value-of select="$margin.note.width"/>
  333. </xsl:otherwise>
  334. </xsl:choose>
  335. </xsl:with-param>
  336. <xsl:with-param name="start.indent">
  337. <xsl:choose>
  338. <xsl:when test="$position = 'start' or
  339. $position = 'left'">0pt</xsl:when>
  340. <xsl:when test="$position = 'end' or
  341. $position = 'right'">0.5em</xsl:when>
  342. <xsl:otherwise>0pt</xsl:otherwise>
  343. </xsl:choose>
  344. </xsl:with-param>
  345. <xsl:with-param name="end.indent">
  346. <xsl:choose>
  347. <xsl:when test="$position = 'start' or
  348. $position = 'left'">0.5em</xsl:when>
  349. <xsl:when test="$position = 'end' or
  350. $position = 'right'">0pt</xsl:when>
  351. <xsl:otherwise>0pt</xsl:otherwise>
  352. </xsl:choose>
  353. </xsl:with-param>
  354. </xsl:call-template>
  355. </xsl:template>
  356. <xsl:template match="sidebar/title" mode="margin.note.title.mode">
  357. <xsl:apply-templates/>
  358. </xsl:template>
  359. <!-- ==================================================================== -->
  360. <xsl:template match="abstract">
  361. <fo:block xsl:use-attribute-sets="abstract.properties">
  362. <xsl:call-template name="anchor"/>
  363. <xsl:apply-templates/>
  364. </fo:block>
  365. </xsl:template>
  366. <xsl:template match="abstract/title|abstract/info/title">
  367. <fo:block xsl:use-attribute-sets="abstract.title.properties">
  368. <xsl:apply-templates/>
  369. </fo:block>
  370. </xsl:template>
  371. <!-- ==================================================================== -->
  372. <xsl:template match="msgset">
  373. <xsl:apply-templates/>
  374. </xsl:template>
  375. <xsl:template match="msgentry">
  376. <xsl:call-template name="block.object"/>
  377. </xsl:template>
  378. <xsl:template match="simplemsgentry">
  379. <xsl:call-template name="block.object"/>
  380. </xsl:template>
  381. <xsl:template match="msg">
  382. <xsl:call-template name="block.object"/>
  383. </xsl:template>
  384. <xsl:template match="msgmain">
  385. <xsl:apply-templates/>
  386. </xsl:template>
  387. <xsl:template match="msgsub">
  388. <xsl:apply-templates/>
  389. </xsl:template>
  390. <xsl:template match="msgrel">
  391. <xsl:apply-templates/>
  392. </xsl:template>
  393. <xsl:template match="msgtext">
  394. <xsl:apply-templates/>
  395. </xsl:template>
  396. <xsl:template match="msginfo">
  397. <xsl:call-template name="block.object"/>
  398. </xsl:template>
  399. <xsl:template match="msglevel">
  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="'MsgLevel'"/>
  406. </xsl:call-template>
  407. </fo:inline>
  408. <xsl:apply-templates/>
  409. </fo:block>
  410. </xsl:template>
  411. <xsl:template match="msgorig">
  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="'MsgOrig'"/>
  418. </xsl:call-template>
  419. </fo:inline>
  420. <xsl:apply-templates/>
  421. </fo:block>
  422. </xsl:template>
  423. <xsl:template match="msgaud">
  424. <fo:block>
  425. <fo:inline font-weight="bold"
  426. keep-with-next.within-line="always">
  427. <xsl:call-template name="gentext.template">
  428. <xsl:with-param name="context" select="'msgset'"/>
  429. <xsl:with-param name="name" select="'MsgAud'"/>
  430. </xsl:call-template>
  431. </fo:inline>
  432. <xsl:apply-templates/>
  433. </fo:block>
  434. </xsl:template>
  435. <xsl:template match="msgexplan">
  436. <xsl:call-template name="block.object"/>
  437. </xsl:template>
  438. <xsl:template match="msgexplan/title">
  439. <fo:block font-weight="bold"
  440. keep-with-next.within-column="always"
  441. hyphenate="false">
  442. <xsl:apply-templates/>
  443. </fo:block>
  444. </xsl:template>
  445. <!-- ==================================================================== -->
  446. <!-- For better or worse, revhistory is allowed in content... -->
  447. <xsl:template match="revhistory">
  448. <fo:table table-layout="fixed" xsl:use-attribute-sets="revhistory.table.properties">
  449. <xsl:call-template name="anchor"/>
  450. <fo:table-column column-number="1" column-width="proportional-column-width(1)"/>
  451. <fo:table-column column-number="2" column-width="proportional-column-width(1)"/>
  452. <fo:table-column column-number="3" column-width="proportional-column-width(1)"/>
  453. <fo:table-body start-indent="0pt" end-indent="0pt">
  454. <fo:table-row>
  455. <fo:table-cell number-columns-spanned="3" xsl:use-attribute-sets="revhistory.table.cell.properties">
  456. <fo:block xsl:use-attribute-sets="revhistory.title.properties">
  457. <xsl:call-template name="gentext">
  458. <xsl:with-param name="key" select="'RevHistory'"/>
  459. </xsl:call-template>
  460. </fo:block>
  461. </fo:table-cell>
  462. </fo:table-row>
  463. <xsl:apply-templates/>
  464. </fo:table-body>
  465. </fo:table>
  466. </xsl:template>
  467. <xsl:template match="revhistory/revision">
  468. <xsl:variable name="revnumber" select="revnumber"/>
  469. <xsl:variable name="revdate" select="date"/>
  470. <xsl:variable name="revauthor" select="authorinitials|author"/>
  471. <xsl:variable name="revremark" select="revremark|revdescription"/>
  472. <fo:table-row>
  473. <fo:table-cell xsl:use-attribute-sets="revhistory.table.cell.properties">
  474. <fo:block>
  475. <xsl:call-template name="anchor"/>
  476. <xsl:if test="$revnumber">
  477. <xsl:call-template name="gentext">
  478. <xsl:with-param name="key" select="'Revision'"/>
  479. </xsl:call-template>
  480. <xsl:call-template name="gentext.space"/>
  481. <xsl:apply-templates select="$revnumber[1]"/>
  482. </xsl:if>
  483. </fo:block>
  484. </fo:table-cell>
  485. <fo:table-cell xsl:use-attribute-sets="revhistory.table.cell.properties">
  486. <fo:block>
  487. <xsl:apply-templates select="$revdate[1]"/>
  488. </fo:block>
  489. </fo:table-cell>
  490. <fo:table-cell xsl:use-attribute-sets="revhistory.table.cell.properties">
  491. <fo:block>
  492. <xsl:for-each select="$revauthor">
  493. <xsl:apply-templates select="."/>
  494. <xsl:if test="position() != last()">
  495. <xsl:text>, </xsl:text>
  496. </xsl:if>
  497. </xsl:for-each>
  498. </fo:block>
  499. </fo:table-cell>
  500. </fo:table-row>
  501. <xsl:if test="$revremark">
  502. <fo:table-row>
  503. <fo:table-cell number-columns-spanned="3" xsl:use-attribute-sets="revhistory.table.cell.properties">
  504. <fo:block>
  505. <xsl:apply-templates select="$revremark[1]"/>
  506. </fo:block>
  507. </fo:table-cell>
  508. </fo:table-row>
  509. </xsl:if>
  510. </xsl:template>
  511. <xsl:template match="revision/revnumber">
  512. <xsl:apply-templates/>
  513. </xsl:template>
  514. <xsl:template match="revision/date">
  515. <xsl:apply-templates/>
  516. </xsl:template>
  517. <xsl:template match="revision/authorinitials">
  518. <xsl:apply-templates/>
  519. </xsl:template>
  520. <xsl:template match="revision/author">
  521. <xsl:apply-templates/>
  522. </xsl:template>
  523. <xsl:template match="revision/revremark">
  524. <xsl:apply-templates/>
  525. </xsl:template>
  526. <xsl:template match="revision/revdescription">
  527. <xsl:apply-templates/>
  528. </xsl:template>
  529. <!-- ==================================================================== -->
  530. <xsl:template match="ackno">
  531. <fo:block xsl:use-attribute-sets="normal.para.spacing">
  532. <xsl:call-template name="anchor"/>
  533. <xsl:apply-templates/>
  534. </fo:block>
  535. </xsl:template>
  536. <!-- ==================================================================== -->
  537. <xsl:template match="highlights">
  538. <xsl:call-template name="block.object"/>
  539. </xsl:template>
  540. <!-- ==================================================================== -->
  541. </xsl:stylesheet>