plain.xsl 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  1. <?xml version="1.0" encoding="ASCII"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns="http://www.w3.org/1999/xhtml"
  4. xmlns:xlink="http://www.w3.org/1999/xlink"
  5. xmlns:db="http://docbook.org/ns/docbook"
  6. xmlns:dbs="http://docbook.org/ns/docbook-slides"
  7. xmlns:exsl="http://exslt.org/common"
  8. exclude-result-prefixes="dbs db xlink"
  9. extension-element-prefixes="exsl"
  10. version="1.0">
  11. <xsl:import href="../../xhtml/chunk.xsl"/>
  12. <xsl:import href="../common/common.xsl"/>
  13. <xsl:import href="plain-titlepage.xsl"/>
  14. <xsl:import href="param.xsl"/>
  15. <xsl:param name="local.l10n.xml" select="document('')"/>
  16. <i18n xmlns="http://docbook.sourceforge.net/xmlns/l10n/1.0">
  17. <l:l10n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" language="en">
  18. <l:gentext key="Foilgroup" text="Foil Group"/>
  19. <l:gentext key="Foil" text="Foil"/>
  20. <l:gentext key="Speakernotes" text="Speaker Notes"/>
  21. <l:gentext key="Handoutnotes" text="Handout Notes"/>
  22. <l:gentext key="SVGImage" text="SVG image"/>
  23. <l:gentext key="MathMLFormula" text="MathML formula"/>
  24. <l:context name="title">
  25. <l:gentext key="foil" text="Foil %n %t"/>
  26. <l:gentext key="foilgroup" text="Foil %n %t"/>
  27. </l:context>
  28. </l:l10n>
  29. </i18n>
  30. <!-- Overrides from DocBook XSL -->
  31. <xsl:template name="process.qanda.toc"/>
  32. <!-- Main content starts here -->
  33. <xsl:template name="xhtml.head">
  34. <meta name="generator" content="DocBook Slides Stylesheets V{$VERSION}"/>
  35. <link rel="stylesheet" href="{$user.css}" type="text/css"/>
  36. </xsl:template>
  37. <xsl:template name="slideshow.head"/>
  38. <xsl:template name="slideshow.content">
  39. <div class="presentation">
  40. <xsl:if test="$generate.titlepage != 0">
  41. <xsl:apply-templates select="/dbs:slides" mode="titlepage"/>
  42. </xsl:if>
  43. <xsl:apply-templates select="/dbs:slides/dbs:foil|dbs:slides/dbs:foilgroup"/>
  44. </div>
  45. </xsl:template>
  46. <xsl:template match="/dbs:slides" mode="titlepage">
  47. <xsl:call-template name="slides.titlepage"/>
  48. </xsl:template>
  49. <xsl:template name="slide.notes">
  50. <xsl:if test="($generate.speakernotes != 0) and ./dbs:speakernotes">
  51. <div class="notes">
  52. <h2 class="notes">
  53. <xsl:call-template name="gentext">
  54. <xsl:with-param name="key" select="'Speakernotes'"/>
  55. </xsl:call-template>
  56. </h2>
  57. <xsl:apply-templates select="dbs:speakernotes" mode="notes.mode"/>
  58. </div>
  59. </xsl:if>
  60. <xsl:if test="($generate.handoutnotes != 0) and ./dbs:handoutnotes">
  61. <div class="handout">
  62. <h2 class="handout">
  63. <xsl:call-template name="gentext">
  64. <xsl:with-param name="key" select="'Handoutnotes'"/>
  65. </xsl:call-template>
  66. </h2>
  67. <xsl:apply-templates select="dbs:handoutnotes" mode="notes.mode"/>
  68. </div>
  69. </xsl:if>
  70. </xsl:template>
  71. <xsl:template match="/">
  72. <html>
  73. <xsl:if test="/dbs:slides/@xml:lang">
  74. <xsl:attribute name="xml:lang">
  75. <xsl:value-of select="/dbs:slides/@xml:lang"/>
  76. </xsl:attribute>
  77. </xsl:if>
  78. <head>
  79. <title>
  80. <xsl:call-template name="get.title">
  81. <xsl:with-param name="ctx" select="/dbs:slides"/>
  82. </xsl:call-template>
  83. </title>
  84. <xsl:call-template name="xhtml.head"/>
  85. </head>
  86. <body>
  87. <xsl:call-template name="slideshow.head"/>
  88. <xsl:call-template name="slideshow.content"/>
  89. </body>
  90. </html>
  91. </xsl:template>
  92. <xsl:template name="foilgroup.content">
  93. <xsl:apply-templates select="*[not(self::dbs:foil)]"/>
  94. <xsl:if test="($generate.foilgroup.toc != 0)">
  95. <xsl:choose>
  96. <xsl:when test="($generate.foilgroup.numbered.toc != 0)">
  97. <ol>
  98. <xsl:for-each select="dbs:foil">
  99. <li><xsl:call-template name="get.title"/></li>
  100. </xsl:for-each>
  101. </ol>
  102. </xsl:when>
  103. <xsl:otherwise>
  104. <ul>
  105. <xsl:for-each select="dbs:foil">
  106. <li><xsl:call-template name="get.title"/></li>
  107. </xsl:for-each>
  108. </ul>
  109. </xsl:otherwise>
  110. </xsl:choose>
  111. </xsl:if>
  112. </xsl:template>
  113. <xsl:template name="foil.classes">
  114. <xsl:variable name="classValue">
  115. <xsl:call-template name="process.dbs.attributes">
  116. <!-- Do not put incremental or collapsible on foils -->
  117. <xsl:with-param name="attributeSet" select="self::*/@dbs:style"/>
  118. <xsl:with-param name="stored">
  119. <xsl:value-of select="'slide'"/>
  120. <xsl:if test="@*[namespace-uri() = 'http://docbook.org/ns/docbook-slides']">
  121. <xsl:text> </xsl:text>
  122. </xsl:if>
  123. </xsl:with-param>
  124. </xsl:call-template>
  125. </xsl:variable>
  126. <xsl:attribute name="class">
  127. <xsl:value-of select="$classValue"/>
  128. </xsl:attribute>
  129. </xsl:template>
  130. <xsl:template match="dbs:foilgroup">
  131. <xsl:call-template name="generate.anchor"/>
  132. <div>
  133. <xsl:call-template name="foil.classes"/>
  134. <xsl:choose>
  135. <xsl:when test="($wrap.slidecontent != 0)">
  136. <div class="slidecontent">
  137. <xsl:call-template name="foilgroup.content"/>
  138. </div>
  139. </xsl:when>
  140. <xsl:otherwise>
  141. <xsl:call-template name="foilgroup.content"/>
  142. </xsl:otherwise>
  143. </xsl:choose>
  144. <xsl:call-template name="slide.notes"/>
  145. </div>
  146. <xsl:apply-templates select="dbs:foil"/>
  147. </xsl:template>
  148. <xsl:template match="dbs:foil">
  149. <xsl:call-template name="generate.anchor"/>
  150. <div>
  151. <xsl:call-template name="foil.classes"/>
  152. <xsl:choose>
  153. <xsl:when test="($wrap.slidecontent != 0)">
  154. <div class="slidecontent">
  155. <xsl:apply-templates select="*"/>
  156. </div>
  157. </xsl:when>
  158. <xsl:otherwise>
  159. <xsl:apply-templates/>
  160. </xsl:otherwise>
  161. </xsl:choose>
  162. <xsl:call-template name="process.footnotes"/>
  163. <xsl:call-template name="slide.notes"/>
  164. </div>
  165. </xsl:template>
  166. <xsl:template match="dbs:handoutnotes"/>
  167. <xsl:template match="dbs:speakernotes"/>
  168. <xsl:template match="dbs:handoutnotes" mode="notes.mode">
  169. <div class="handoutnotes">
  170. <xsl:apply-templates/>
  171. </div>
  172. </xsl:template>
  173. <xsl:template match="dbs:speakernotes" mode="notes.mode">
  174. <div class="speakernotes">
  175. <xsl:apply-templates/>
  176. </div>
  177. </xsl:template>
  178. <xsl:template name="process.dbs.attributes">
  179. <xsl:param name="attributeSet"/>
  180. <xsl:param name="stored" select="''"/>
  181. <xsl:variable name="gotIncremental">
  182. <xsl:if test="((local-name($attributeSet[1]) = 'incremental') and ($attributeSet[1] = '1'))">1</xsl:if>
  183. </xsl:variable>
  184. <xsl:variable name="enableIncremental">
  185. <xsl:if test="($disable.incremental = '0') and ($gotIncremental = '1')">1</xsl:if>
  186. </xsl:variable>
  187. <xsl:variable name="gotCollapsible">
  188. <xsl:if test="((local-name($attributeSet[1]) = 'collapsible') and ($attributeSet[1] = '1'))">1</xsl:if>
  189. </xsl:variable>
  190. <xsl:variable name="enableCollapsible">
  191. <xsl:if test="($disable.collapsible = '0') and ($gotCollapsible = '1')">1</xsl:if>
  192. </xsl:variable>
  193. <xsl:variable name="append">
  194. <xsl:choose>
  195. <xsl:when test="local-name($attributeSet[1]) = 'style'">
  196. <xsl:value-of select="$attributeSet[1]"/>
  197. </xsl:when>
  198. <xsl:when test="$enableCollapsible = '1'">
  199. <xsl:value-of select="'outline'"/>
  200. </xsl:when>
  201. <xsl:when test="$enableIncremental = '1'">
  202. <xsl:value-of select="'incremental'"/>
  203. </xsl:when>
  204. </xsl:choose>
  205. <xsl:if test="count($attributeSet) &gt; 1">
  206. <xsl:text> </xsl:text>
  207. </xsl:if>
  208. </xsl:variable>
  209. <xsl:choose>
  210. <xsl:when test="not($attributeSet)">
  211. <xsl:value-of select="$stored"/>
  212. </xsl:when>
  213. <xsl:when test="count($attributeSet) &lt;= 1">
  214. <xsl:value-of select="concat($stored, $append)"/>
  215. </xsl:when>
  216. <xsl:otherwise>
  217. <xsl:call-template name="process.dbs.attributes">
  218. <xsl:with-param name="attributeSet" select="$attributeSet[position() != 1]"/>
  219. <xsl:with-param name="stored" select="concat($stored, $append)"/>
  220. </xsl:call-template>
  221. </xsl:otherwise>
  222. </xsl:choose>
  223. </xsl:template>
  224. <xsl:template match="dbs:block">
  225. <xsl:variable name="classValue">
  226. <xsl:call-template name="process.dbs.attributes">
  227. <xsl:with-param name="attributeSet" select="(ancestor-or-self::*/@dbs:incremental)[last()] | (ancestor-or-self::*/@dbs:collapsible)[last()] | self::*/@dbs:style"/>
  228. </xsl:call-template>
  229. </xsl:variable>
  230. <div class="{$classValue}">
  231. <xsl:apply-templates/>
  232. </div>
  233. </xsl:template>
  234. <xsl:template match="db:info">
  235. <xsl:apply-templates select="db:title|db:titleabbrev|db:subtitle|db:author|db:authorgroup/db:author"/>
  236. </xsl:template>
  237. <xsl:template match="db:title|db:titleabbrev">
  238. <xsl:if test="not(self::db:title) or (not(preceding-sibling::db:titleabbrev) and not(following-sibling::db:titleabbrev))">
  239. <h1 class="title"><xsl:value-of select="."/></h1>
  240. </xsl:if>
  241. </xsl:template>
  242. <xsl:template match="db:subtitle">
  243. <h1 class="subtitle"><xsl:value-of select="."/></h1>
  244. </xsl:template>
  245. <xsl:template match="db:author">
  246. <h3 class="author"><xsl:apply-templates select="db:personname|db:orgname"/></h3>
  247. <h4 class="email"><xsl:apply-templates select="db:email"/></h4>
  248. <xsl:if test="db:affiliation">
  249. <h4 class="affiliation"><xsl:value-of select="db:affiliation"/></h4>
  250. </xsl:if>
  251. </xsl:template>
  252. <xsl:template match="db:email">
  253. <a>
  254. <xsl:attribute name="href">
  255. <xsl:text>mailto:</xsl:text><xsl:value-of select="."/>
  256. </xsl:attribute>
  257. &lt;<xsl:value-of select="."/>&gt;
  258. </a>
  259. </xsl:template>
  260. <xsl:template name="list.content">
  261. <xsl:variable name="classValue">
  262. <xsl:call-template name="process.dbs.attributes">
  263. <xsl:with-param name="attributeSet" select="(ancestor-or-self::*/@dbs:incremental)[last()] | (ancestor-or-self::*/@dbs:collapsible)[last()] | self::*/@dbs:style"/>
  264. </xsl:call-template>
  265. </xsl:variable>
  266. <xsl:attribute name="class">
  267. <xsl:value-of select="$classValue"/>
  268. </xsl:attribute>
  269. <xsl:apply-templates select="*"/>
  270. </xsl:template>
  271. <xsl:template match="db:itemizedlist">
  272. <ul>
  273. <xsl:call-template name="list.content"/>
  274. </ul>
  275. </xsl:template>
  276. <xsl:template match="db:orderedlist">
  277. <ol>
  278. <xsl:call-template name="list.content"/>
  279. </ol>
  280. </xsl:template>
  281. <xsl:template match="db:mediaobject">
  282. <xsl:variable name="classValue">
  283. <xsl:call-template name="process.dbs.attributes">
  284. <xsl:with-param name="attributeSet" select="(ancestor-or-self::*/@dbs:incremental)[last()] | (ancestor-or-self::*/@dbs:collapsible)[last()] | self::*/@dbs:style"/>
  285. </xsl:call-template>
  286. </xsl:variable>
  287. <div class="{$classValue}">
  288. <xsl:apply-templates select="db:imageobject[1]"/>
  289. </div>
  290. </xsl:template>
  291. <xsl:template name="bibliography.titlepage"/>
  292. <xsl:template match="db:bibliosource" mode="bibliography.mode">
  293. <span>
  294. <xsl:call-template name="common.html.attributes"/>
  295. <xsl:call-template name="id.attribute"/>
  296. <xsl:choose>
  297. <xsl:when test="@xlink:href">
  298. <a href="{@xlink:href}">
  299. <xsl:apply-templates mode="bibliography.mode"/>
  300. </a>
  301. </xsl:when>
  302. <xsl:otherwise>
  303. <xsl:apply-templates mode="bibliomixed.mode"/>
  304. </xsl:otherwise>
  305. </xsl:choose>
  306. </span>
  307. </xsl:template>
  308. <xsl:template name="href.target.uri">
  309. <xsl:param name="object" select="."/>
  310. <xsl:variable name="ischunk">
  311. <xsl:call-template name="chunk">
  312. <xsl:with-param name="node" select="$object"/>
  313. </xsl:call-template>
  314. </xsl:variable>
  315. <xsl:if test="$ischunk='0'">
  316. <xsl:text>#</xsl:text>
  317. <xsl:call-template name="object.id">
  318. <xsl:with-param name="object" select="$object"/>
  319. </xsl:call-template>
  320. </xsl:if>
  321. </xsl:template>
  322. <xsl:template match="dbs:foil|dbs:foilgroup" mode="xref-to">
  323. <xsl:call-template name="gentext">
  324. <xsl:with-param name="key" select="'Foil'"/>
  325. </xsl:call-template>
  326. <xsl:call-template name="gentext.space"/>
  327. <xsl:value-of select="count(preceding::dbs:foil|preceding::dbs:foilgroup) + 1"/>
  328. <xsl:text>: </xsl:text>
  329. <xsl:call-template name="get.title"/>
  330. </xsl:template>
  331. <xsl:template name="extension.process.image.attributes">
  332. <xsl:variable name="classValue">
  333. <xsl:call-template name="process.dbs.attributes">
  334. <xsl:with-param name="attributeSet" select="(ancestor-or-self::*/@dbs:incremental)[last()] | (ancestor-or-self::*/@dbs:collapsible)[last()] | self::*/@dbs:style"/>
  335. </xsl:call-template>
  336. </xsl:variable>
  337. <xsl:if test="./@*[namespace-uri() = 'http://docbook.org/ns/docbook-slides']">
  338. <xsl:attribute name="class">
  339. <xsl:value-of select="$classValue"/>
  340. </xsl:attribute>
  341. </xsl:if>
  342. </xsl:template>
  343. <xsl:template match="*[namespace-uri() = 'http://www.w3.org/2000/svg']">
  344. <xsl:call-template name="handle.embedded">
  345. <xsl:with-param name="modeParam" select="$svg.embedding.mode"/>
  346. <xsl:with-param name="fileExt" select="'.svg'"/>
  347. <xsl:with-param name="mimeType" select="'image/svg+xml'"/>
  348. <xsl:with-param name="gentextKey" select="'SVGImage'"/>
  349. </xsl:call-template>
  350. </xsl:template>
  351. <xsl:template match="*[namespace-uri() = 'http://www.w3.org/1998/Math/MathML']">
  352. <xsl:call-template name="handle.embedded">
  353. <xsl:with-param name="modeParam" select="$mml.embedding.mode"/>
  354. <xsl:with-param name="fileExt" select="'.mml'"/>
  355. <xsl:with-param name="mimeType" select="'application/mathml-presentation+xml'"/>
  356. <xsl:with-param name="gentextKey" select="'MathMLFormula'"/>
  357. </xsl:call-template>
  358. </xsl:template>
  359. <xsl:template name="handle.embedded">
  360. <xsl:param name="modeParam">inline</xsl:param>
  361. <xsl:param name="fileExt"/>
  362. <xsl:param name="mimeType"/>
  363. <xsl:param name="gentextKey"/>
  364. <xsl:choose>
  365. <xsl:when test="$modeParam = 'inline'">
  366. <xsl:copy-of select="."/>
  367. </xsl:when>
  368. <xsl:otherwise>
  369. <xsl:variable name="id">
  370. <xsl:call-template name="object.id"/>
  371. </xsl:variable>
  372. <xsl:variable name="fname">
  373. <xsl:value-of select="concat($id, $fileExt)"/>
  374. </xsl:variable>
  375. <exsl:document href="{$fname}">
  376. <xsl:copy-of select="."/>
  377. </exsl:document>
  378. <xsl:choose>
  379. <xsl:when test="$modeParam = 'object'">
  380. <object data="{$fname}" type="{$mimeType}"/>
  381. </xsl:when>
  382. <xsl:when test="$modeParam = 'image'">
  383. <img alt="{$mimeType} object" src="{$fname}"/>
  384. </xsl:when>
  385. <xsl:when test="$modeParam = 'link'">
  386. <a href="{$fname}">
  387. <xsl:call-template name="gentext">
  388. <xsl:with-param name="key" select="$gentextKey"/>
  389. </xsl:call-template>
  390. </a>
  391. </xsl:when>
  392. <xsl:when test="$modeParam = 'iframe'">
  393. <iframe src="{$fname}"/>
  394. </xsl:when>
  395. <xsl:when test="$modeParam = 'embed'">
  396. <embed src="{$fname}" type="{$mimeType}" />
  397. </xsl:when>
  398. <xsl:otherwise>
  399. <xsl:message terminate="yes">
  400. Unknown processing mode <xsl:value-of select="$modeParam"/>.
  401. </xsl:message>
  402. </xsl:otherwise>
  403. </xsl:choose>
  404. </xsl:otherwise>
  405. </xsl:choose>
  406. </xsl:template>
  407. <xsl:template name="generate.anchor">
  408. <a>
  409. <xsl:attribute name="name">
  410. <xsl:call-template name="object.id"/>
  411. </xsl:attribute>
  412. </a>
  413. </xsl:template>
  414. <xsl:template name="slide.copyright">
  415. <div class="copyright">
  416. <xsl:call-template name="gentext">
  417. <xsl:with-param name="key" select="'Copyright'"/>
  418. </xsl:call-template>
  419. <xsl:call-template name="gentext.space"/>
  420. <xsl:text>&#xa9;</xsl:text>
  421. <xsl:call-template name="gentext.space"/>
  422. <xsl:value-of select="/dbs:slides/db:info/db:copyright/db:year"/>
  423. <xsl:call-template name="gentext.space"/>
  424. <xsl:value-of select="/dbs:slides/db:info/db:copyright/db:holder"/>
  425. </div>
  426. </xsl:template>
  427. <xsl:template name="slide.pubdate">
  428. <div class="pubdate">
  429. <xsl:call-template name="gentext">
  430. <xsl:with-param name="key" select="'Published'"/>
  431. </xsl:call-template>
  432. <xsl:text>: </xsl:text>
  433. <xsl:value-of select="/dbs:slides/db:info/db:pubdate"/>
  434. </div>
  435. </xsl:template>
  436. <xsl:template match="/" mode="slide.header.mode"/>
  437. <xsl:template match="/" mode="slide.footer.mode">
  438. <xsl:if test="($generate.copyright != 0) and /dbs:slides/db:info/db:copyright">
  439. <xsl:call-template name="slide.copyright"/>
  440. </xsl:if>
  441. <xsl:if test="($generate.pubdate != 0) and /dbs:slides/db:info/db:pubdate">
  442. <xsl:call-template name="slide.pubdate"/>
  443. </xsl:if>
  444. </xsl:template>
  445. </xsl:stylesheet>