block.xsl 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. <?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. version='1.0'>
  4. <!-- ********************************************************************
  5. $Id: block.xsl 9667 2012-11-26 23:10:44Z bobstayton $
  6. ********************************************************************
  7. This file is part of the XSL DocBook Stylesheet distribution.
  8. See ../README or http://docbook.sf.net/release/xsl/current/ for
  9. copyright and other information.
  10. ******************************************************************** -->
  11. <!-- ==================================================================== -->
  12. <!-- What should we do about styling blockinfo? -->
  13. <xsl:template match="blockinfo|info">
  14. <!-- suppress -->
  15. </xsl:template>
  16. <!-- ==================================================================== -->
  17. <xsl:template name="block.object">
  18. <div>
  19. <xsl:call-template name="common.html.attributes"/>
  20. <xsl:call-template name="id.attribute"/>
  21. <xsl:call-template name="anchor"/>
  22. <xsl:apply-templates/>
  23. </div>
  24. </xsl:template>
  25. <!-- ==================================================================== -->
  26. <xsl:template match="para">
  27. <xsl:call-template name="paragraph">
  28. <xsl:with-param name="class">
  29. <xsl:if test="@role and $para.propagates.style != 0">
  30. <xsl:value-of select="@role"/>
  31. </xsl:if>
  32. </xsl:with-param>
  33. <xsl:with-param name="content">
  34. <xsl:if test="position() = 1 and parent::listitem">
  35. <xsl:call-template name="anchor">
  36. <xsl:with-param name="node" select="parent::listitem"/>
  37. </xsl:call-template>
  38. </xsl:if>
  39. <xsl:call-template name="anchor"/>
  40. <xsl:apply-templates/>
  41. </xsl:with-param>
  42. </xsl:call-template>
  43. </xsl:template>
  44. <xsl:template name="paragraph">
  45. <xsl:param name="class" select="''"/>
  46. <xsl:param name="content"/>
  47. <xsl:variable name="p">
  48. <p>
  49. <xsl:call-template name="id.attribute"/>
  50. <xsl:choose>
  51. <xsl:when test="$class != ''">
  52. <xsl:call-template name="common.html.attributes">
  53. <xsl:with-param name="class" select="$class"/>
  54. </xsl:call-template>
  55. </xsl:when>
  56. <xsl:otherwise>
  57. <xsl:call-template name="common.html.attributes">
  58. <xsl:with-param name="class" select="''"/>
  59. </xsl:call-template>
  60. </xsl:otherwise>
  61. </xsl:choose>
  62. <xsl:copy-of select="$content"/>
  63. </p>
  64. </xsl:variable>
  65. <xsl:choose>
  66. <xsl:when test="$html.cleanup != 0">
  67. <xsl:call-template name="unwrap.p">
  68. <xsl:with-param name="p" select="$p"/>
  69. </xsl:call-template>
  70. </xsl:when>
  71. <xsl:otherwise>
  72. <xsl:copy-of select="$p"/>
  73. </xsl:otherwise>
  74. </xsl:choose>
  75. </xsl:template>
  76. <xsl:template match="simpara">
  77. <!-- see also listitem/simpara in lists.xsl -->
  78. <p>
  79. <xsl:call-template name="id.attribute"/>
  80. <xsl:call-template name="locale.html.attributes"/>
  81. <xsl:if test="@role and $para.propagates.style != 0">
  82. <xsl:apply-templates select="." mode="class.attribute">
  83. <xsl:with-param name="class" select="@role"/>
  84. </xsl:apply-templates>
  85. </xsl:if>
  86. <xsl:call-template name="anchor"/>
  87. <xsl:apply-templates/>
  88. </p>
  89. </xsl:template>
  90. <xsl:template match="formalpara">
  91. <xsl:call-template name="paragraph">
  92. <xsl:with-param name="class">
  93. <xsl:if test="@role and $para.propagates.style != 0">
  94. <xsl:value-of select="@role"/>
  95. </xsl:if>
  96. </xsl:with-param>
  97. <xsl:with-param name="content">
  98. <xsl:call-template name="anchor"/>
  99. <xsl:apply-templates/>
  100. </xsl:with-param>
  101. </xsl:call-template>
  102. </xsl:template>
  103. <!-- Only use title from info -->
  104. <xsl:template match="formalpara/info">
  105. <xsl:apply-templates select="title"/>
  106. </xsl:template>
  107. <xsl:template match="formalpara/title|formalpara/info/title">
  108. <xsl:variable name="titleStr">
  109. <xsl:apply-templates/>
  110. </xsl:variable>
  111. <xsl:variable name="lastChar">
  112. <xsl:if test="$titleStr != ''">
  113. <xsl:value-of select="substring($titleStr,string-length($titleStr),1)"/>
  114. </xsl:if>
  115. </xsl:variable>
  116. <xsl:choose>
  117. <xsl:when test="$make.clean.html != 0">
  118. <span class="formalpara-title">
  119. <xsl:copy-of select="$titleStr"/>
  120. <xsl:if test="$lastChar != ''
  121. and not(contains($runinhead.title.end.punct, $lastChar))">
  122. <xsl:value-of select="$runinhead.default.title.end.punct"/>
  123. </xsl:if>
  124. <xsl:text>&#160;</xsl:text>
  125. </span>
  126. </xsl:when>
  127. <xsl:otherwise>
  128. <b>
  129. <xsl:copy-of select="$titleStr"/>
  130. <xsl:if test="$lastChar != ''
  131. and not(contains($runinhead.title.end.punct, $lastChar))">
  132. <xsl:value-of select="$runinhead.default.title.end.punct"/>
  133. </xsl:if>
  134. <xsl:text>&#160;</xsl:text>
  135. </b>
  136. </xsl:otherwise>
  137. </xsl:choose>
  138. </xsl:template>
  139. <xsl:template match="formalpara/para">
  140. <xsl:apply-templates/>
  141. </xsl:template>
  142. <!-- ==================================================================== -->
  143. <xsl:template match="blockquote">
  144. <div>
  145. <xsl:call-template name="common.html.attributes"/>
  146. <xsl:call-template name="id.attribute"/>
  147. <xsl:call-template name="anchor"/>
  148. <xsl:choose>
  149. <xsl:when test="attribution">
  150. <table border="{$table.border.off}" class="blockquote">
  151. <xsl:if test="$css.decoration != 0">
  152. <xsl:attribute name="style">
  153. <xsl:text>width: 100%; cellspacing: 0; cellpadding: 0;</xsl:text>
  154. </xsl:attribute>
  155. </xsl:if>
  156. <xsl:if test="$div.element != 'section'">
  157. <xsl:attribute name="summary">Block quote</xsl:attribute>
  158. </xsl:if>
  159. <tr>
  160. <td width="10%" valign="top">&#160;</td>
  161. <td width="80%" valign="top">
  162. <xsl:apply-templates select="child::*[local-name(.)!='attribution']"/>
  163. </td>
  164. <td width="10%" valign="top">&#160;</td>
  165. </tr>
  166. <tr>
  167. <td width="10%" valign="top">&#160;</td>
  168. <td colspan="2" align="{$direction.align.end}" valign="top">
  169. <xsl:text>--</xsl:text>
  170. <xsl:apply-templates select="attribution"/>
  171. </td>
  172. </tr>
  173. </table>
  174. </xsl:when>
  175. <xsl:otherwise>
  176. <blockquote>
  177. <xsl:call-template name="common.html.attributes"/>
  178. <xsl:apply-templates/>
  179. </blockquote>
  180. </xsl:otherwise>
  181. </xsl:choose>
  182. </div>
  183. </xsl:template>
  184. <xsl:template match="blockquote/title|blockquote/info/title">
  185. <xsl:choose>
  186. <xsl:when test="$make.clean.html != 0">
  187. <div class="blockquote-title">
  188. <xsl:apply-templates/>
  189. </div>
  190. </xsl:when>
  191. <xsl:otherwise>
  192. <div class="blockquote-title">
  193. <p>
  194. <b>
  195. <xsl:apply-templates/>
  196. </b>
  197. </p>
  198. </div>
  199. </xsl:otherwise>
  200. </xsl:choose>
  201. </xsl:template>
  202. <!-- Use an em dash per Chicago Manual of Style and https://sourceforge.net/tracker/index.php?func=detail&aid=2793878&group_id=21935&atid=373747 -->
  203. <xsl:template match="epigraph">
  204. <div>
  205. <xsl:call-template name="common.html.attributes"/>
  206. <xsl:call-template name="id.attribute"/>
  207. <xsl:apply-templates select="para|simpara|formalpara|literallayout"/>
  208. <xsl:if test="attribution">
  209. <div class="attribution">
  210. <span>&#x2014;<xsl:apply-templates select="attribution"/></span>
  211. </div>
  212. </xsl:if>
  213. </div>
  214. </xsl:template>
  215. <xsl:template match="attribution">
  216. <span>
  217. <xsl:call-template name="common.html.attributes"/>
  218. <xsl:call-template name="id.attribute"/>
  219. <xsl:apply-templates/>
  220. </span>
  221. </xsl:template>
  222. <!-- ==================================================================== -->
  223. <xsl:template match="sidebar">
  224. <div>
  225. <xsl:call-template name="common.html.attributes"/>
  226. <xsl:call-template name="id.attribute"/>
  227. <xsl:call-template name="anchor"/>
  228. <xsl:call-template name="sidebar.titlepage"/>
  229. <xsl:apply-templates/>
  230. </div>
  231. </xsl:template>
  232. <xsl:template match="abstract/title|sidebar/title">
  233. </xsl:template>
  234. <xsl:template match="sidebar/sidebarinfo|sidebar/info"/>
  235. <xsl:template match="abstract">
  236. <div>
  237. <xsl:call-template name="common.html.attributes"/>
  238. <xsl:call-template name="anchor"/>
  239. <xsl:call-template name="formal.object.heading">
  240. <xsl:with-param name="title">
  241. <xsl:apply-templates select="." mode="title.markup">
  242. <xsl:with-param name="allow-anchors" select="'1'"/>
  243. </xsl:apply-templates>
  244. </xsl:with-param>
  245. </xsl:call-template>
  246. <xsl:apply-templates/>
  247. </div>
  248. </xsl:template>
  249. <!-- ==================================================================== -->
  250. <xsl:template match="msgset">
  251. <xsl:apply-templates/>
  252. </xsl:template>
  253. <xsl:template match="msgentry">
  254. <xsl:call-template name="block.object"/>
  255. </xsl:template>
  256. <xsl:template match="simplemsgentry">
  257. <xsl:call-template name="block.object"/>
  258. </xsl:template>
  259. <xsl:template match="msg">
  260. <xsl:call-template name="block.object"/>
  261. </xsl:template>
  262. <xsl:template match="msgmain">
  263. <xsl:apply-templates/>
  264. </xsl:template>
  265. <xsl:template match="msgmain/title">
  266. <xsl:choose>
  267. <xsl:when test="$make.clean.html != 0">
  268. <span class="msgmain-title">
  269. <xsl:apply-templates/>
  270. </span>
  271. </xsl:when>
  272. <xsl:otherwise>
  273. <b><xsl:apply-templates/></b>
  274. </xsl:otherwise>
  275. </xsl:choose>
  276. </xsl:template>
  277. <xsl:template match="msgsub">
  278. <xsl:apply-templates/>
  279. </xsl:template>
  280. <xsl:template match="msgsub/title">
  281. <xsl:choose>
  282. <xsl:when test="$make.clean.html != 0">
  283. <span class="msgsub-title">
  284. <xsl:apply-templates/>
  285. </span>
  286. </xsl:when>
  287. <xsl:otherwise>
  288. <b><xsl:apply-templates/></b>
  289. </xsl:otherwise>
  290. </xsl:choose>
  291. </xsl:template>
  292. <xsl:template match="msgrel">
  293. <xsl:apply-templates/>
  294. </xsl:template>
  295. <xsl:template match="msgrel/title">
  296. <xsl:choose>
  297. <xsl:when test="$make.clean.html != 0">
  298. <span class="msgrel-title">
  299. <xsl:apply-templates/>
  300. </span>
  301. </xsl:when>
  302. <xsl:otherwise>
  303. <b><xsl:apply-templates/></b>
  304. </xsl:otherwise>
  305. </xsl:choose>
  306. </xsl:template>
  307. <xsl:template match="msgtext">
  308. <xsl:apply-templates/>
  309. </xsl:template>
  310. <xsl:template match="msginfo">
  311. <xsl:call-template name="block.object"/>
  312. </xsl:template>
  313. <xsl:template match="msglevel">
  314. <xsl:choose>
  315. <xsl:when test="$make.clean.html != 0">
  316. <div class="msglevel">
  317. <span class="msglevel-title">
  318. <xsl:call-template name="gentext.template">
  319. <xsl:with-param name="context" select="'msgset'"/>
  320. <xsl:with-param name="name" select="'MsgLevel'"/>
  321. </xsl:call-template>
  322. </span>
  323. <xsl:apply-templates/>
  324. </div>
  325. </xsl:when>
  326. <xsl:otherwise>
  327. <p>
  328. <b>
  329. <xsl:call-template name="gentext.template">
  330. <xsl:with-param name="context" select="'msgset'"/>
  331. <xsl:with-param name="name" select="'MsgLevel'"/>
  332. </xsl:call-template>
  333. </b>
  334. <xsl:apply-templates/>
  335. </p>
  336. </xsl:otherwise>
  337. </xsl:choose>
  338. </xsl:template>
  339. <xsl:template match="msgorig">
  340. <xsl:choose>
  341. <xsl:when test="$make.clean.html != 0">
  342. <div class="msgorig">
  343. <span class="msgorig-title">
  344. <xsl:call-template name="gentext.template">
  345. <xsl:with-param name="context" select="'msgset'"/>
  346. <xsl:with-param name="name" select="'MsgOrig'"/>
  347. </xsl:call-template>
  348. </span>
  349. <xsl:apply-templates/>
  350. </div>
  351. </xsl:when>
  352. <xsl:otherwise>
  353. <p>
  354. <b>
  355. <xsl:call-template name="gentext.template">
  356. <xsl:with-param name="context" select="'msgset'"/>
  357. <xsl:with-param name="name" select="'MsgOrig'"/>
  358. </xsl:call-template>
  359. </b>
  360. <xsl:apply-templates/>
  361. </p>
  362. </xsl:otherwise>
  363. </xsl:choose>
  364. </xsl:template>
  365. <xsl:template match="msgaud">
  366. <xsl:choose>
  367. <xsl:when test="$make.clean.html != 0">
  368. <div class="msgaud">
  369. <span class="msgaud-title">
  370. <xsl:call-template name="gentext.template">
  371. <xsl:with-param name="context" select="'msgset'"/>
  372. <xsl:with-param name="name" select="'MsgAud'"/>
  373. </xsl:call-template>
  374. </span>
  375. <xsl:apply-templates/>
  376. </div>
  377. </xsl:when>
  378. <xsl:otherwise>
  379. <p>
  380. <b>
  381. <xsl:call-template name="gentext.template">
  382. <xsl:with-param name="context" select="'msgset'"/>
  383. <xsl:with-param name="name" select="'MsgAud'"/>
  384. </xsl:call-template>
  385. </b>
  386. <xsl:apply-templates/>
  387. </p>
  388. </xsl:otherwise>
  389. </xsl:choose>
  390. </xsl:template>
  391. <xsl:template match="msgexplan">
  392. <xsl:call-template name="block.object"/>
  393. </xsl:template>
  394. <xsl:template match="msgexplan/title">
  395. <xsl:choose>
  396. <xsl:when test="$make.clean.html != 0">
  397. <div class="msgexplan">
  398. <span class="msgexplan-title">
  399. <xsl:apply-templates/>
  400. </span>
  401. </div>
  402. </xsl:when>
  403. <xsl:otherwise>
  404. <p>
  405. <b>
  406. <xsl:apply-templates/>
  407. </b>
  408. </p>
  409. </xsl:otherwise>
  410. </xsl:choose>
  411. </xsl:template>
  412. <!-- ==================================================================== -->
  413. <xsl:template match="revhistory">
  414. <div>
  415. <xsl:call-template name="common.html.attributes"/>
  416. <xsl:call-template name="id.attribute"/>
  417. <table>
  418. <xsl:if test="$css.decoration != 0">
  419. <xsl:attribute name="style">
  420. <xsl:text>border-style:solid; width:100%;</xsl:text>
  421. </xsl:attribute>
  422. </xsl:if>
  423. <!-- include summary attribute if not HTML5 -->
  424. <xsl:if test="$div.element != 'section'">
  425. <xsl:attribute name="summary">
  426. <xsl:call-template name="gentext">
  427. <xsl:with-param name="key">revhistory</xsl:with-param>
  428. </xsl:call-template>
  429. </xsl:attribute>
  430. </xsl:if>
  431. <tr>
  432. <th align="{$direction.align.start}" valign="top" colspan="3">
  433. <b>
  434. <xsl:call-template name="gentext">
  435. <xsl:with-param name="key" select="'RevHistory'"/>
  436. </xsl:call-template>
  437. </b>
  438. </th>
  439. </tr>
  440. <xsl:apply-templates/>
  441. </table>
  442. </div>
  443. </xsl:template>
  444. <xsl:template match="revhistory/revision">
  445. <xsl:variable name="revnumber" select="revnumber"/>
  446. <xsl:variable name="revdate" select="date"/>
  447. <xsl:variable name="revauthor" select="authorinitials|author"/>
  448. <xsl:variable name="revremark" select="revremark|revdescription"/>
  449. <tr>
  450. <td align="{$direction.align.start}">
  451. <xsl:if test="$revnumber">
  452. <xsl:call-template name="gentext">
  453. <xsl:with-param name="key" select="'Revision'"/>
  454. </xsl:call-template>
  455. <xsl:call-template name="gentext.space"/>
  456. <xsl:apply-templates select="$revnumber"/>
  457. </xsl:if>
  458. </td>
  459. <td align="{$direction.align.start}">
  460. <xsl:apply-templates select="$revdate"/>
  461. </td>
  462. <xsl:choose>
  463. <xsl:when test="count($revauthor)=0">
  464. <td align="{$direction.align.start}">
  465. <xsl:call-template name="dingbat">
  466. <xsl:with-param name="dingbat">nbsp</xsl:with-param>
  467. </xsl:call-template>
  468. </td>
  469. </xsl:when>
  470. <xsl:otherwise>
  471. <td align="{$direction.align.start}">
  472. <xsl:for-each select="$revauthor">
  473. <xsl:apply-templates select="."/>
  474. <xsl:if test="position() != last()">
  475. <xsl:text>, </xsl:text>
  476. </xsl:if>
  477. </xsl:for-each>
  478. </td>
  479. </xsl:otherwise>
  480. </xsl:choose>
  481. </tr>
  482. <xsl:if test="$revremark">
  483. <tr>
  484. <td align="{$direction.align.start}" colspan="3">
  485. <xsl:apply-templates select="$revremark"/>
  486. </td>
  487. </tr>
  488. </xsl:if>
  489. </xsl:template>
  490. <xsl:template match="revision/revnumber">
  491. <xsl:apply-templates/>
  492. </xsl:template>
  493. <xsl:template match="revision/date">
  494. <xsl:apply-templates/>
  495. </xsl:template>
  496. <xsl:template match="revision/authorinitials">
  497. <xsl:text>, </xsl:text>
  498. <xsl:apply-templates/>
  499. </xsl:template>
  500. <xsl:template match="revision/authorinitials[1]" priority="2">
  501. <xsl:apply-templates/>
  502. </xsl:template>
  503. <xsl:template match="revision/revremark">
  504. <xsl:apply-templates/>
  505. </xsl:template>
  506. <xsl:template match="revision/revdescription">
  507. <xsl:apply-templates/>
  508. </xsl:template>
  509. <!-- ==================================================================== -->
  510. <xsl:template match="ackno|acknowledgements[parent::article]">
  511. <xsl:call-template name="block.object"/>
  512. </xsl:template>
  513. <!-- ==================================================================== -->
  514. <xsl:template match="highlights">
  515. <xsl:call-template name="block.object"/>
  516. </xsl:template>
  517. <!-- ==================================================================== -->
  518. </xsl:stylesheet>