titlepage.xsl 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310
  1. <?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:t="http://nwalsh.com/docbook/xsl/template/1.0"
  4. xmlns:param="http://nwalsh.com/docbook/xsl/template/1.0/param"
  5. xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
  6. xmlns:fo="http://www.w3.org/1999/XSL/Format"
  7. xmlns:exsl="http://exslt.org/common"
  8. exclude-result-prefixes="doc t param exsl"
  9. version='1.0'>
  10. <!-- ********************************************************************
  11. $Id: titlepage.xsl 9600 2012-09-11 12:12:09Z kosek $
  12. ********************************************************************
  13. This file is part of the XSL DocBook Stylesheet distribution.
  14. See ../README or http://docbook.sf.net/release/xsl/current/ for
  15. copyright and other information.
  16. ******************************************************************** -->
  17. <!-- ==================================================================== -->
  18. <!-- Namespace for wrapper elements. Please set it for XHTML. -->
  19. <xsl:param name="ns">
  20. <!-- Guess correct setting for cases where parameter is not supplied -->
  21. <xsl:choose>
  22. <xsl:when test="//*[namespace-uri() = 'http://www.w3.org/1999/XSL/Format']">http://www.w3.org/1999/XSL/Format</xsl:when>
  23. <xsl:when test="//*[namespace-uri() = 'http://www.w3.org/1999/xhtml']">http://www.w3.org/1999/xhtml</xsl:when>
  24. </xsl:choose>
  25. </xsl:param>
  26. <xsl:template match="/">
  27. <xsl:text>&#x0a;</xsl:text>
  28. <xsl:apply-templates/>
  29. <xsl:text>&#x0a;</xsl:text>
  30. </xsl:template>
  31. <doc:reference xmlns="" xml:id="template">
  32. <?dbhtml dir="template"?>
  33. <?dbhtml filename="index.html"?>
  34. <info>
  35. <title>Titlepage Template Stylesheet Reference</title>
  36. <releaseinfo role="meta">
  37. $Id: titlepage.xsl 9600 2012-09-11 12:12:09Z kosek $
  38. </releaseinfo>
  39. </info>
  40. <partintro xml:id="intro_partintro">
  41. <title>Introduction</title>
  42. <para>This is technical reference documentation for the
  43. “titlepage” templates in the DocBook XSL Stylesheets.</para>
  44. <para>This is not intended to be user documentation. It is
  45. provided for developers writing customization layers for the
  46. stylesheets.</para>
  47. </partintro>
  48. </doc:reference>
  49. <!-- ==================================================================== -->
  50. <xsl:preserve-space elements="*"/>
  51. <xsl:strip-space elements="xsl:* t:*"/>
  52. <!-- ==================================================================== -->
  53. <doc:template match="t:templates" xmlns="" id="templates">
  54. <refpurpose>Construct a stylesheet for the templates provided</refpurpose>
  55. <refdescription>
  56. <para>The <literal>t:templates</literal> element is the root of a
  57. set of templates. This template creates an appropriate
  58. <literal>xsl:stylesheet</literal> for the templates.</para>
  59. <para>If the <literal>t:templates</literal> element has a
  60. <literal>base-stylesheet</literal> attribute, an
  61. <literal>xsl:import</literal> statement is constructed for it.</para>
  62. </refdescription>
  63. </doc:template>
  64. <xsl:template match="t:templates">
  65. <xsl:element name="xsl:stylesheet">
  66. <xsl:for-each select="document('')/xsl:stylesheet/namespace::exsl">
  67. <xsl:copy/>
  68. </xsl:for-each>
  69. <xsl:attribute name="version">1.0</xsl:attribute>
  70. <xsl:attribute name="exclude-result-prefixes">exsl</xsl:attribute>
  71. <xsl:text>&#xA;&#xA;</xsl:text>
  72. <xsl:comment>
  73. <xsl:text> This stylesheet was created by </xsl:text>
  74. <xsl:text>template/titlepage.xsl</xsl:text>
  75. </xsl:comment>
  76. <xsl:if test="@t:base-stylesheet">
  77. <xsl:text>&#xA;&#xA;</xsl:text>
  78. <xsl:element name="xsl:import">
  79. <xsl:attribute name="href">
  80. <xsl:value-of select="@t:base-stylesheet"/>
  81. </xsl:attribute>
  82. </xsl:element>
  83. </xsl:if>
  84. <xsl:apply-templates/>
  85. <xsl:text>&#xA;&#xA;</xsl:text>
  86. </xsl:element>
  87. </xsl:template>
  88. <!-- ==================================================================== -->
  89. <doc:template match="xsl:*" xmlns="" id="star">
  90. <refpurpose>Copy xsl: elements straight through</refpurpose>
  91. <refdescription>
  92. <para>This template simply copies the xsl: elements
  93. straight through into the result tree.</para>
  94. </refdescription>
  95. </doc:template>
  96. <xsl:template match="xsl:*">
  97. <xsl:apply-templates select="." mode="copy"/>
  98. </xsl:template>
  99. <!-- ==================================================================== -->
  100. <doc:template match="t:titlepage" xmlns="" id="titlepage">
  101. <refpurpose>Create the templates necessary to construct a title page</refpurpose>
  102. <refdescription>
  103. <para>The <literal>t:titlepage</literal> element creates a set of
  104. templates for processing the titlepage for an element. The
  105. <quote>root</quote> of this template set is the template named
  106. <quote><literal>wrapper.titlepage</literal></quote>. That is the
  107. template that should be called to generate the title page.
  108. </para>
  109. <para>The <literal>t:titlepage</literal> element has three attributes:
  110. <variablelist>
  111. <varlistentry><term>element</term>
  112. <listitem><para>The name of the source document element for which
  113. these templates apply. In other words, to make a title page for the
  114. <tag>article</tag> element, set the
  115. <tag class="attribute">element</tag> attribute to
  116. <quote><literal>article</literal></quote>. This attribute is required.
  117. </para></listitem>
  118. </varlistentry>
  119. <varlistentry><term>wrapper</term>
  120. <listitem><para>The entire title page can be wrapped with an element.
  121. This attribute identifies that element.
  122. </para></listitem>
  123. </varlistentry>
  124. <varlistentry><term>class</term>
  125. <listitem><para>If the <tag class="attribute">class</tag> attribute
  126. is set, a <tag class="attribute">class</tag> attribute with this
  127. value will be added to the wrapper element that surrounds the entire
  128. title page.
  129. </para></listitem>
  130. </varlistentry>
  131. </variablelist>
  132. </para>
  133. <para>Any other attributes are copied through literally to the
  134. wrapper element.</para>
  135. <para>The content of a <literal>t:titlepage</literal> is one or
  136. more <literal>t:titlepage-content</literal>,
  137. <literal>t:titlepage-separator</literal>, and
  138. <literal>t:titlepage-before</literal> elements.</para>
  139. <para>Each of these elements may be provided for the <quote>recto</quote>
  140. and <quote>verso</quote> sides of the title page.</para>
  141. </refdescription>
  142. </doc:template>
  143. <xsl:template match="t:titlepage">
  144. <!-- process the children to make the templates for the content,
  145. separator, and before elements -->
  146. <xsl:apply-templates/>
  147. <!-- output the title page template -->
  148. <xsl:text>&#xA;&#xA;</xsl:text>
  149. <xsl:element name="xsl:template">
  150. <xsl:attribute name="name">
  151. <xsl:value-of select="@t:element"/>
  152. <xsl:text>.titlepage</xsl:text>
  153. </xsl:attribute>
  154. <xsl:text>&#xA; </xsl:text>
  155. <xsl:element name="{@t:wrapper}" namespace="{$ns}">
  156. <xsl:apply-templates select="@*" mode="copy.literal.atts"/>
  157. <xsl:text>&#xA; </xsl:text>
  158. <xsl:element name="xsl:variable">
  159. <xsl:attribute name="name">recto.content</xsl:attribute>
  160. <xsl:text>&#xA; </xsl:text>
  161. <xsl:element name="xsl:call-template">
  162. <xsl:attribute name="name">
  163. <xsl:value-of select="@t:element"/>
  164. <xsl:text>.titlepage.before.recto</xsl:text>
  165. </xsl:attribute>
  166. </xsl:element>
  167. <xsl:text>&#xA; </xsl:text>
  168. <xsl:element name="xsl:call-template">
  169. <xsl:attribute name="name">
  170. <xsl:value-of select="@t:element"/>
  171. <xsl:text>.titlepage.recto</xsl:text>
  172. </xsl:attribute>
  173. </xsl:element>
  174. <xsl:text>&#xA; </xsl:text>
  175. </xsl:element>
  176. <xsl:text>&#xA; </xsl:text>
  177. <xsl:element name="xsl:variable">
  178. <xsl:attribute name="name">recto.elements.count</xsl:attribute>
  179. <xsl:text>&#xA; </xsl:text>
  180. <xsl:element name="xsl:choose">
  181. <xsl:text>&#xA; </xsl:text>
  182. <xsl:element name="xsl:when">
  183. <xsl:attribute name="test">function-available('exsl:node-set')</xsl:attribute>
  184. <xsl:element name="xsl:value-of">
  185. <xsl:attribute name="select">count(exsl:node-set($recto.content)/*)</xsl:attribute>
  186. </xsl:element>
  187. </xsl:element>
  188. <xsl:text>&#xA; </xsl:text>
  189. <xsl:element name="xsl:when">
  190. <xsl:attribute name="test">contains(system-property('xsl:vendor'), 'Apache Software Foundation')</xsl:attribute>
  191. <xsl:text>&#xA; </xsl:text>
  192. <xsl:comment>Xalan quirk</xsl:comment>
  193. <xsl:element name="xsl:value-of">
  194. <xsl:attribute name="select">count(exsl:node-set($recto.content)/*)</xsl:attribute>
  195. </xsl:element>
  196. </xsl:element>
  197. <xsl:text>&#xA; </xsl:text>
  198. <xsl:element name="xsl:otherwise">
  199. <xsl:text>1</xsl:text>
  200. </xsl:element>
  201. <xsl:text>&#xA; </xsl:text>
  202. </xsl:element>
  203. <xsl:text>&#xA; </xsl:text>
  204. </xsl:element>
  205. <xsl:text>&#xA; </xsl:text>
  206. <xsl:element name="xsl:if">
  207. <xsl:attribute name="test">(normalize-space($recto.content) != '') or ($recto.elements.count > 0)</xsl:attribute>
  208. <xsl:text>&#xA; </xsl:text>
  209. <xsl:element name="{@t:wrapper}" namespace="{$ns}">
  210. <xsl:apply-templates select="t:titlepage-content[@t:side='recto']/@*"
  211. mode="copy.literal.atts"/>
  212. <xsl:element name="xsl:copy-of">
  213. <xsl:attribute name="select">$recto.content</xsl:attribute>
  214. </xsl:element>
  215. </xsl:element>
  216. <xsl:text>&#xA; </xsl:text>
  217. </xsl:element>
  218. <xsl:text>&#xA; </xsl:text>
  219. <xsl:element name="xsl:variable">
  220. <xsl:attribute name="name">verso.content</xsl:attribute>
  221. <xsl:text>&#xA; </xsl:text>
  222. <xsl:element name="xsl:call-template">
  223. <xsl:attribute name="name">
  224. <xsl:value-of select="@t:element"/>
  225. <xsl:text>.titlepage.before.verso</xsl:text>
  226. </xsl:attribute>
  227. </xsl:element>
  228. <xsl:text>&#xA; </xsl:text>
  229. <xsl:element name="xsl:call-template">
  230. <xsl:attribute name="name">
  231. <xsl:value-of select="@t:element"/>
  232. <xsl:text>.titlepage.verso</xsl:text>
  233. </xsl:attribute>
  234. </xsl:element>
  235. <xsl:text>&#xA; </xsl:text>
  236. </xsl:element>
  237. <xsl:text>&#xA; </xsl:text>
  238. <xsl:element name="xsl:variable">
  239. <xsl:attribute name="name">verso.elements.count</xsl:attribute>
  240. <xsl:text>&#xA; </xsl:text>
  241. <xsl:element name="xsl:choose">
  242. <xsl:text>&#xA; </xsl:text>
  243. <xsl:element name="xsl:when">
  244. <xsl:attribute name="test">function-available('exsl:node-set')</xsl:attribute>
  245. <xsl:element name="xsl:value-of">
  246. <xsl:attribute name="select">count(exsl:node-set($verso.content)/*)</xsl:attribute>
  247. </xsl:element>
  248. </xsl:element>
  249. <xsl:text>&#xA; </xsl:text>
  250. <xsl:element name="xsl:when">
  251. <xsl:attribute name="test">contains(system-property('xsl:vendor'), 'Apache Software Foundation')</xsl:attribute>
  252. <xsl:text>&#xA; </xsl:text>
  253. <xsl:comment>Xalan quirk</xsl:comment>
  254. <xsl:element name="xsl:value-of">
  255. <xsl:attribute name="select">count(exsl:node-set($verso.content)/*)</xsl:attribute>
  256. </xsl:element>
  257. </xsl:element>
  258. <xsl:text>&#xA; </xsl:text>
  259. <xsl:element name="xsl:otherwise">
  260. <xsl:text>1</xsl:text>
  261. </xsl:element>
  262. <xsl:text>&#xA; </xsl:text>
  263. </xsl:element>
  264. <xsl:text>&#xA; </xsl:text>
  265. </xsl:element>
  266. <xsl:text>&#xA; </xsl:text>
  267. <xsl:element name="xsl:if">
  268. <xsl:attribute name="test">(normalize-space($verso.content) != '') or ($verso.elements.count > 0)</xsl:attribute>
  269. <xsl:text>&#xA; </xsl:text>
  270. <xsl:element name="{@t:wrapper}" namespace="{$ns}">
  271. <xsl:apply-templates select="t:titlepage-content[@t:side='verso']/@*"
  272. mode="copy.literal.atts"/>
  273. <xsl:element name="xsl:copy-of">
  274. <xsl:attribute name="select">$verso.content</xsl:attribute>
  275. </xsl:element>
  276. </xsl:element>
  277. <xsl:text>&#xA; </xsl:text>
  278. </xsl:element>
  279. <xsl:text>&#xA; </xsl:text>
  280. <xsl:element name="xsl:call-template">
  281. <xsl:attribute name="name">
  282. <xsl:value-of select="@t:element"/>
  283. <xsl:text>.titlepage.separator</xsl:text>
  284. </xsl:attribute>
  285. </xsl:element>
  286. <xsl:text>&#xA; </xsl:text>
  287. </xsl:element>
  288. <xsl:text>&#xA;</xsl:text>
  289. </xsl:element>
  290. <!-- If we're not importing a base stylesheet, output a default rule
  291. for the recto- and verso-mode elements. (If we are importing a
  292. base stylesheet, don't do this since the *-rules in the stylesheet
  293. will totally override the rules that would otherwise be imported.)
  294. -->
  295. <xsl:if test="not(../@t:base-stylesheet)">
  296. <!-- output a default rule for the recto-modes elements -->
  297. <xsl:text>&#xA;&#xA;</xsl:text>
  298. <xsl:element name="xsl:template">
  299. <xsl:attribute name="match">*</xsl:attribute>
  300. <xsl:attribute name="mode">
  301. <xsl:value-of select="@t:element"/>
  302. <xsl:text>.titlepage.recto.mode</xsl:text>
  303. </xsl:attribute>
  304. <xsl:text>&#xA; </xsl:text>
  305. <xsl:comment> if an element isn't found in this mode, </xsl:comment>
  306. <xsl:text>&#xA; </xsl:text>
  307. <xsl:comment> try the generic titlepage.mode </xsl:comment>
  308. <xsl:text>&#xA; </xsl:text>
  309. <xsl:element name="xsl:apply-templates">
  310. <xsl:attribute name="select">.</xsl:attribute>
  311. <xsl:attribute name="mode">titlepage.mode</xsl:attribute>
  312. </xsl:element>
  313. <xsl:text>&#xA;</xsl:text>
  314. </xsl:element>
  315. <!-- output a default rule for the verso-modes elements -->
  316. <xsl:text>&#xA;&#xA;</xsl:text>
  317. <xsl:element name="xsl:template">
  318. <xsl:attribute name="match">*</xsl:attribute>
  319. <xsl:attribute name="mode">
  320. <xsl:value-of select="@t:element"/>
  321. <xsl:text>.titlepage.verso.mode</xsl:text>
  322. </xsl:attribute>
  323. <xsl:text>&#xA; </xsl:text>
  324. <xsl:comment> if an element isn't found in this mode, </xsl:comment>
  325. <xsl:text>&#xA; </xsl:text>
  326. <xsl:comment> try the generic titlepage.mode </xsl:comment>
  327. <xsl:text>&#xA; </xsl:text>
  328. <xsl:element name="xsl:apply-templates">
  329. <xsl:attribute name="select">.</xsl:attribute>
  330. <xsl:attribute name="mode">titlepage.mode</xsl:attribute>
  331. </xsl:element>
  332. <xsl:text>&#xA;</xsl:text>
  333. </xsl:element>
  334. </xsl:if>
  335. <!-- output default templates for each of the elements listed in -->
  336. <!-- the titlepage-content. If a template is suppressed or forced -->
  337. <!-- to be off, or has already been output, don't output it. -->
  338. <xsl:for-each select="t:titlepage-content/*">
  339. <xsl:variable name="thisnode" select="."/>
  340. <xsl:if test="(not(@t:suppress-template) or @t:suppress-template='0')
  341. and (not(@t:force) or @t:force='0')
  342. and (not(preceding-sibling::*[name(.)=name($thisnode)]))">
  343. <xsl:text>&#xA;&#xA;</xsl:text>
  344. <xsl:element name="xsl:template">
  345. <xsl:attribute name="match">
  346. <xsl:value-of select="name(.)"/>
  347. </xsl:attribute>
  348. <xsl:attribute name="mode">
  349. <xsl:value-of select="../../@t:element"/>
  350. <xsl:text>.titlepage.</xsl:text>
  351. <xsl:value-of select="../@t:side"/>
  352. <xsl:text>.auto.mode</xsl:text>
  353. </xsl:attribute>
  354. <xsl:text>&#xA;</xsl:text>
  355. <xsl:element name="{../../@t:wrapper}" namespace="{$ns}">
  356. <xsl:attribute name="xsl:use-attribute-sets">
  357. <xsl:value-of select="../../@t:element"/>
  358. <xsl:text>.titlepage.</xsl:text>
  359. <xsl:value-of select="../@t:side"/>
  360. <xsl:text>.style</xsl:text>
  361. </xsl:attribute>
  362. <xsl:for-each select="@*">
  363. <xsl:if test="not(starts-with(namespace-uri(.),
  364. 'http://nwalsh.com/docbook/xsl/template/1.0'))">
  365. <xsl:attribute name="{name(.)}" namespace="{namespace-uri(.)}">
  366. <xsl:value-of select="."/>
  367. </xsl:attribute>
  368. </xsl:if>
  369. </xsl:for-each>
  370. <xsl:text>&#xA;</xsl:text>
  371. <xsl:choose>
  372. <xsl:when test="@t:named-template">
  373. <xsl:element name="xsl:call-template">
  374. <xsl:attribute name="name">
  375. <xsl:value-of select="@t:named-template"/>
  376. </xsl:attribute>
  377. <xsl:for-each select="@*">
  378. <xsl:if test="namespace-uri(.)='http://nwalsh.com/docbook/xsl/template/1.0/param'">
  379. <xsl:text>&#xA;</xsl:text>
  380. <xsl:element name="xsl:with-param">
  381. <xsl:attribute name="name">
  382. <xsl:value-of select="local-name(.)"/>
  383. </xsl:attribute>
  384. <xsl:attribute name="select">
  385. <xsl:value-of select="."/>
  386. </xsl:attribute>
  387. </xsl:element>
  388. </xsl:if>
  389. </xsl:for-each>
  390. <xsl:text>&#xA;</xsl:text>
  391. </xsl:element>
  392. </xsl:when>
  393. <xsl:otherwise>
  394. <xsl:element name="xsl:apply-templates">
  395. <xsl:attribute name="select">.</xsl:attribute>
  396. <xsl:attribute name="mode">
  397. <xsl:value-of select="../../@t:element"/>
  398. <xsl:text>.titlepage.</xsl:text>
  399. <xsl:value-of select="../@t:side"/>
  400. <xsl:text>.mode</xsl:text>
  401. </xsl:attribute>
  402. </xsl:element>
  403. </xsl:otherwise>
  404. </xsl:choose>
  405. <xsl:text>&#xA;</xsl:text>
  406. </xsl:element>
  407. <xsl:text>&#xA;</xsl:text>
  408. </xsl:element>
  409. </xsl:if>
  410. </xsl:for-each>
  411. </xsl:template>
  412. <doc:template match="@*" mode="copy.literal.atts" xmlns=""
  413. id="attr_star_in_copy.literal.atts">
  414. <refpurpose>Copy t:titlepage attributes</refpurpose>
  415. <refdescription>
  416. <para>This template copies all of the <quote>other</quote> attributes
  417. from a <literal>t:titlepage</literal> element onto the specified
  418. wrapper.</para>
  419. </refdescription>
  420. </doc:template>
  421. <xsl:template match="@*" mode="copy.literal.atts">
  422. <xsl:if test="not(starts-with(namespace-uri(.),
  423. 'http://nwalsh.com/docbook/xsl/template/1.0'))">
  424. <xsl:attribute name="{name(.)}">
  425. <xsl:value-of select="."/>
  426. </xsl:attribute>
  427. </xsl:if>
  428. </xsl:template>
  429. <!-- ==================================================================== -->
  430. <doc:template match="t:titlepage-content" id="titlepage-content">
  431. <refpurpose>Create templates for the content of one side of a title page</refpurpose>
  432. <refdescription>
  433. <para>The title page content, that is, the elements from the source
  434. document that are rendered on the title page, can be controlled independently
  435. for the recto and verso sides of the title page.</para>
  436. <para>The <literal>t:titlepage-content</literal> element has two attributes:
  437. <variablelist>
  438. <varlistentry><term>side</term>
  439. <listitem><para>Identifies the side of the page to which this title
  440. page content applies. The
  441. <tag class="attribute">side</tag> attribute is required and
  442. must be set to either
  443. <quote><literal>recto</literal></quote> or
  444. <quote><literal>verso</literal></quote>. In addition, you must specify
  445. exactly one <literal>t:titlepage-content</literal> for each side
  446. within each <literal>t:titlepage</literal>.</para>
  447. </listitem>
  448. </varlistentry>
  449. <varlistentry><term>order</term>
  450. <listitem><para>Indicates how the order of the elements presented on
  451. the title page is determined. If the
  452. <tag class="attribute">order</tag> is
  453. <quote><literal>document</literal></quote>, the elements are presented
  454. in document order. Otherwise (if the
  455. <tag class="attribute">order</tag> is
  456. <quote><literal>stylesheet</literal></quote>), the elements are presented
  457. in the order that they appear in the template (and consequently in
  458. the stylesheet).</para>
  459. </listitem>
  460. </varlistentry>
  461. </variablelist>
  462. </para>
  463. <para>The content of a <literal>t:titlepage-content</literal> element is
  464. a list of element names. These names should be unqualified. They identify
  465. the elements in the source document that should appear on the title page.
  466. </para>
  467. <para>Each element may have a single attribute:
  468. <tag class="attribute">predicate</tag>. The value of this
  469. attribute is used as a predicate for the expression that matches
  470. the element on which it occurs.</para>
  471. <para>In other words, to put only the first three authors on the
  472. recto-side of a title
  473. page, you could specify:
  474. <screen><![CDATA[
  475. <t:titlepage-contents side="recto">
  476. <!-- other titlepage elements -->
  477. <author predicate="[count(previous-sibling::author)<2]"/>
  478. <!-- other titlepage elements -->
  479. </t:titlepage-contents>
  480. ]]></screen>
  481. </para>
  482. <para>Usually, the elements so named are empty. But it is possible to
  483. make one level of selection within them. Suppose that you want to
  484. process <literal>authorgroup</literal> elements on the title page, but
  485. you want to select only proper authors, editors, or corporate authors,
  486. not collaborators or other credited authors.</para>
  487. <para>In that case, you can put a <literal>t:or</literal> group inside
  488. the <literal>authorgroup</literal> element:
  489. <screen><![CDATA[
  490. <t:titlepage-contents side="recto">
  491. <!-- other titlepage elements -->
  492. <authorgroup>
  493. <t:or>
  494. <author/>
  495. <editor/>
  496. <corpauthor/>
  497. </t:or>
  498. </authorgroup>
  499. <!-- other titlepage elements -->
  500. </t:titlepage-contents>
  501. ]]></screen>
  502. </para>
  503. <para>This will have the effect of automatically generating a template
  504. for processing <literal>authorgroup</literal>s in the title page mode,
  505. selecting only the specified children. If you need more complex processing,
  506. you'll have to construct the templates by hand.</para>
  507. </refdescription>
  508. </doc:template>
  509. <xsl:template match="t:titlepage-content">
  510. <xsl:variable name="side">
  511. <xsl:choose>
  512. <xsl:when test="@t:side='recto' or @t:side='verso'">
  513. <xsl:value-of select="@t:side"/>
  514. </xsl:when>
  515. <xsl:when test="@t:side">
  516. <xsl:message terminate="yes">
  517. <xsl:text>Illegal value specified for @t:side </xsl:text>
  518. <xsl:text>on t:titlepage-content: </xsl:text>
  519. <xsl:value-of select="@t:side"/>
  520. </xsl:message>
  521. </xsl:when>
  522. <xsl:otherwise>
  523. <xsl:message terminate="yes">
  524. <xsl:text>The @t:side attribute is required on </xsl:text>
  525. <xsl:text>t:titlepage-content.</xsl:text>
  526. </xsl:message>
  527. </xsl:otherwise>
  528. </xsl:choose>
  529. </xsl:variable>
  530. <xsl:variable name="mode">
  531. <xsl:value-of select="../@t:element"/>
  532. <xsl:text>.titlepage.</xsl:text>
  533. <xsl:value-of select="$side"/>
  534. <xsl:text>.auto.mode</xsl:text>
  535. </xsl:variable>
  536. <xsl:text>&#xA;&#xA;</xsl:text>
  537. <xsl:element name="xsl:template">
  538. <xsl:attribute name="name">
  539. <xsl:value-of select="../@t:element"/>
  540. <xsl:text>.titlepage.</xsl:text>
  541. <xsl:value-of select="$side"/>
  542. </xsl:attribute>
  543. <xsl:choose>
  544. <!-- if document order is selected, make a huge select statement
  545. on a single xsl:apply-templates to pick out the right elements
  546. for the title page. -->
  547. <xsl:when test="@t:order='document'">
  548. <xsl:if test="count(child::*)&gt;0">
  549. <xsl:element name="xsl:apply-templates">
  550. <xsl:attribute name="mode">
  551. <xsl:value-of select="$mode"/>
  552. </xsl:attribute>
  553. <xsl:attribute name="select">
  554. <xsl:apply-templates mode="document.order"/>
  555. </xsl:attribute>
  556. </xsl:element>
  557. </xsl:if>
  558. </xsl:when>
  559. <!-- otherwise, select each of the elements in the specified order -->
  560. <xsl:otherwise>
  561. <xsl:apply-templates mode="stylesheet.order"/>
  562. </xsl:otherwise>
  563. </xsl:choose>
  564. <xsl:text>&#xA;</xsl:text>
  565. </xsl:element>
  566. <xsl:apply-templates mode="titlepage.specialrules"/>
  567. </xsl:template>
  568. <!-- ==================================================================== -->
  569. <doc:template match="t:titlepage-separator" id="titlepage-separator">
  570. <refpurpose>Create templates for the separator</refpurpose>
  571. <refdescription>
  572. <para>The title page is separated from the content which follows it by
  573. the markup specified in the <literal>t:titlepage-separator</literal>
  574. element.</para>
  575. </refdescription>
  576. </doc:template>
  577. <xsl:template match="t:titlepage-separator">
  578. <xsl:text>&#xA;&#xA;</xsl:text>
  579. <xsl:element name="xsl:template">
  580. <xsl:attribute name="name">
  581. <xsl:value-of select="../@t:element"/>
  582. <xsl:text>.titlepage.separator</xsl:text>
  583. </xsl:attribute>
  584. <xsl:apply-templates mode="copy"/>
  585. <xsl:text>&#xA;</xsl:text>
  586. </xsl:element>
  587. </xsl:template>
  588. <!-- ==================================================================== -->
  589. <doc:template match="t:titlepage-before" id="titlepage-before">
  590. <refpurpose>Create templates for what precedes a title page</refpurpose>
  591. <refdescription>
  592. <para>Each side of the title page is preceded by the markup specified
  593. in the <literal>t:titlepage-before</literal> element for that
  594. side.</para>
  595. </refdescription>
  596. </doc:template>
  597. <xsl:template match="t:titlepage-before">
  598. <xsl:text>&#xA;&#xA;</xsl:text>
  599. <xsl:element name="xsl:template">
  600. <xsl:attribute name="name">
  601. <xsl:value-of select="../@t:element"/>
  602. <xsl:text>.titlepage.before.</xsl:text>
  603. <xsl:value-of select="@t:side"/>
  604. </xsl:attribute>
  605. <xsl:apply-templates mode="copy"/>
  606. <xsl:text>&#xA;</xsl:text>
  607. </xsl:element>
  608. </xsl:template>
  609. <!-- ==================================================================== -->
  610. <doc:template match="*" mode="copy" xmlns="" id="star_in_copy">
  611. <refpurpose>Copy elements</refpurpose>
  612. <refdescription>
  613. <para>This template simply copies the elements that it applies to
  614. straight through into the result tree.</para>
  615. </refdescription>
  616. </doc:template>
  617. <xsl:template match="*" mode="copy">
  618. <xsl:choose>
  619. <xsl:when test="(name(.) = local-name(.)) and namespace-uri(.) != ''">
  620. <xsl:element name="{name(.)}" namespace="{namespace-uri(.)}">
  621. <xsl:apply-templates select="@*" mode="copy"/>
  622. <xsl:apply-templates mode="copy"/>
  623. </xsl:element>
  624. </xsl:when>
  625. <xsl:otherwise>
  626. <xsl:element name="{name(.)}">
  627. <xsl:apply-templates select="@*" mode="copy"/>
  628. <xsl:apply-templates mode="copy"/>
  629. </xsl:element>
  630. </xsl:otherwise>
  631. </xsl:choose>
  632. </xsl:template>
  633. <!-- ==================================================================== -->
  634. <doc:template match="@*" mode="copy" xmlns="" id="attr_star_in_copy">
  635. <refpurpose>Copy attributes</refpurpose>
  636. <refdescription>
  637. <para>This template simply copies the attributes that it applies to
  638. straight through into the result tree.</para>
  639. </refdescription>
  640. </doc:template>
  641. <xsl:template match="@*" mode="copy">
  642. <xsl:choose>
  643. <xsl:when test="(name(.) = local-name(.)) and namespace-uri(.) != ''">
  644. <xsl:attribute name="{name(.)}" namespace="{namespace-uri(.)}">
  645. <xsl:value-of select="."/>
  646. </xsl:attribute>
  647. </xsl:when>
  648. <xsl:otherwise>
  649. <xsl:attribute name="{name(.)}">
  650. <xsl:value-of select="."/>
  651. </xsl:attribute>
  652. </xsl:otherwise>
  653. </xsl:choose>
  654. </xsl:template>
  655. <!-- ==================================================================== -->
  656. <doc:template match="*" mode="document.order" xmlns="" id="attr_star_in_document.order">
  657. <refpurpose>Create rules to process titlepage elements in document order</refpurpose>
  658. <refdescription>
  659. <para>This template is called to process all of the children of the
  660. <literal>t:titlepage-content</literal> element. It creates the hairy
  661. select expression necessary to process each of those elements in
  662. the title page.</para>
  663. <para>Note that this template automatically handles the case where
  664. some DocBook elements, like title and subtitle, can occur both inside
  665. the *info elements where metadata is usually stored and outside.
  666. </para>
  667. <para>It also automatically calculates the name for the *info container
  668. and handles elements that have historically had containers with different
  669. names.</para>
  670. </refdescription>
  671. </doc:template>
  672. <xsl:template match="*" mode="document.order">
  673. <xsl:variable name="docinfo">
  674. <xsl:value-of select="ancestor::t:titlepage/@t:element"/>
  675. <xsl:text>info</xsl:text>
  676. </xsl:variable>
  677. <xsl:variable name="altinfo">
  678. <xsl:choose>
  679. <xsl:when test="ancestor::t:titlepage/@t:element='article'">
  680. <xsl:text>artheader</xsl:text>
  681. </xsl:when>
  682. <xsl:when test="ancestor::t:titlepage/@t:element='qandaset'">
  683. <xsl:text>blockinfo</xsl:text>
  684. </xsl:when>
  685. <xsl:when test="ancestor::t:titlepage/@t:element='section'"></xsl:when>
  686. <xsl:when test="ancestor::t:titlepage/@t:element='sect1'"></xsl:when>
  687. <xsl:when test="ancestor::t:titlepage/@t:element='sect2'"></xsl:when>
  688. <xsl:when test="ancestor::t:titlepage/@t:element='sect3'"></xsl:when>
  689. <xsl:when test="ancestor::t:titlepage/@t:element='sect4'"></xsl:when>
  690. <xsl:when test="ancestor::t:titlepage/@t:element='sect5'"></xsl:when>
  691. <xsl:when test="ancestor::t:titlepage/@t:element='book'"></xsl:when>
  692. <xsl:when test="ancestor::t:titlepage/@t:element='set'"></xsl:when>
  693. <xsl:when test="ancestor::t:titlepage/@t:element='topic'"></xsl:when>
  694. <xsl:otherwise>docinfo</xsl:otherwise>
  695. </xsl:choose>
  696. </xsl:variable>
  697. <xsl:variable name="side">
  698. <xsl:choose>
  699. <xsl:when test="ancestor::t:titlepage-content/@t:side">
  700. <xsl:value-of select="ancestor::t:titlepage-content/@t:side"/>
  701. </xsl:when>
  702. <xsl:otherwise>
  703. <xsl:text>recto</xsl:text>
  704. </xsl:otherwise>
  705. </xsl:choose>
  706. </xsl:variable>
  707. <xsl:variable name="mode">
  708. <xsl:value-of select="ancestor::t:titlepage/@t:element"/>
  709. <xsl:text>.titlepage.</xsl:text>
  710. <xsl:value-of select="$side"/>
  711. <xsl:text>.auto.mode</xsl:text>
  712. </xsl:variable>
  713. <xsl:if test="preceding-sibling::*">
  714. <xsl:text>|</xsl:text>
  715. </xsl:if>
  716. <xsl:value-of select="$docinfo"/>
  717. <xsl:text>/</xsl:text>
  718. <xsl:value-of select="name(.)"/>
  719. <xsl:if test="@t:predicate">
  720. <xsl:value-of select="@t:predicate"/>
  721. </xsl:if>
  722. <xsl:if test="$altinfo != ''">
  723. <xsl:text>|</xsl:text>
  724. <xsl:value-of select="$altinfo"/>
  725. <xsl:text>/</xsl:text>
  726. <xsl:value-of select="name(.)"/>
  727. <xsl:if test="@t:predicate">
  728. <xsl:value-of select="@t:predicate"/>
  729. </xsl:if>
  730. </xsl:if>
  731. <!-- info -->
  732. <xsl:text>|info</xsl:text>
  733. <xsl:text>/</xsl:text>
  734. <xsl:value-of select="name(.)"/>
  735. <xsl:if test="@t:predicate">
  736. <xsl:value-of select="@t:predicate"/>
  737. </xsl:if>
  738. <xsl:if test="local-name(.) = 'title'
  739. or local-name(.) = 'subtitle'
  740. or local-name(.) = 'titleabbrev'">
  741. <xsl:text>|</xsl:text>
  742. <xsl:value-of select="name(.)"/>
  743. <xsl:if test="@t:predicate">
  744. <xsl:value-of select="@t:predicate"/>
  745. </xsl:if>
  746. </xsl:if>
  747. </xsl:template>
  748. <!-- ==================================================================== -->
  749. <doc:template match="*" mode="document.order" xmlns="" id="star_in_document.order">
  750. <refpurpose>Create rules to process titlepage elements in stylesheet order</refpurpose>
  751. <refdescription>
  752. <para>This template is called to process all of the children of the
  753. <literal>t:titlepage-content</literal> element. It creates the set
  754. of <literal>xsl:apply-templates</literal> elements necessary
  755. process each of those elements in the title page.</para>
  756. <para>Note that this template automatically handles the case where
  757. some DocBook elements, like title and subtitle, can occur both inside
  758. the *info elements where metadata is usually stored and outside.
  759. </para>
  760. <para>It also automatically calculates the name for the *info container
  761. and handles elements that have historically had containers with different
  762. names.</para>
  763. </refdescription>
  764. </doc:template>
  765. <xsl:template match="*" mode="stylesheet.order">
  766. <xsl:variable name="docinfo">
  767. <xsl:value-of select="ancestor::t:titlepage/@t:element"/>
  768. <xsl:text>info</xsl:text>
  769. </xsl:variable>
  770. <xsl:variable name="altinfo">
  771. <xsl:choose>
  772. <xsl:when test="ancestor::t:titlepage/@t:element='article'">
  773. <xsl:text>artheader</xsl:text>
  774. </xsl:when>
  775. <xsl:when test="ancestor::t:titlepage/@t:element='qandaset'">
  776. <xsl:text>blockinfo</xsl:text>
  777. </xsl:when>
  778. <xsl:when test="ancestor::t:titlepage/@t:element='section'"></xsl:when>
  779. <xsl:when test="ancestor::t:titlepage/@t:element='sect1'"></xsl:when>
  780. <xsl:when test="ancestor::t:titlepage/@t:element='sect2'"></xsl:when>
  781. <xsl:when test="ancestor::t:titlepage/@t:element='sect3'"></xsl:when>
  782. <xsl:when test="ancestor::t:titlepage/@t:element='sect4'"></xsl:when>
  783. <xsl:when test="ancestor::t:titlepage/@t:element='sect5'"></xsl:when>
  784. <xsl:when test="ancestor::t:titlepage/@t:element='book'"></xsl:when>
  785. <xsl:when test="ancestor::t:titlepage/@t:element='set'"></xsl:when>
  786. <xsl:when test="ancestor::t:titlepage/@t:element='topic'"></xsl:when>
  787. <xsl:otherwise>docinfo</xsl:otherwise>
  788. </xsl:choose>
  789. </xsl:variable>
  790. <xsl:variable name="side">
  791. <xsl:choose>
  792. <xsl:when test="ancestor::t:titlepage-content/@t:side">
  793. <xsl:value-of select="ancestor::t:titlepage-content/@t:side"/>
  794. </xsl:when>
  795. <xsl:otherwise>recto</xsl:otherwise>
  796. </xsl:choose>
  797. </xsl:variable>
  798. <xsl:variable name="mode">
  799. <xsl:value-of select="ancestor::t:titlepage/@t:element"/>
  800. <xsl:text>.titlepage.</xsl:text>
  801. <xsl:value-of select="$side"/>
  802. <xsl:text>.auto.mode</xsl:text>
  803. </xsl:variable>
  804. <xsl:text>&#xA; </xsl:text>
  805. <xsl:choose>
  806. <xsl:when test="@t:force and @t:force != '0'">
  807. <xsl:choose>
  808. <xsl:when test="@t:named-template">
  809. <xsl:element name="{../../@t:wrapper}" namespace="{$ns}">
  810. <xsl:attribute name="xsl:use-attribute-sets">
  811. <xsl:value-of select="../../@t:element"/>
  812. <xsl:text>.titlepage.</xsl:text>
  813. <xsl:value-of select="../@t:side"/>
  814. <xsl:text>.style</xsl:text>
  815. </xsl:attribute>
  816. <xsl:for-each select="@*">
  817. <xsl:if test="not(starts-with(namespace-uri(.),
  818. 'http://nwalsh.com/docbook/xsl/template/1.0'))">
  819. <xsl:attribute name="{name(.)}" namespace="{namespace-uri(.)}">
  820. <xsl:value-of select="."/>
  821. </xsl:attribute>
  822. </xsl:if>
  823. </xsl:for-each>
  824. <xsl:text>&#xA;</xsl:text>
  825. <xsl:element name="xsl:call-template">
  826. <xsl:attribute name="name">
  827. <xsl:value-of select="@t:named-template"/>
  828. </xsl:attribute>
  829. <xsl:for-each select="@*">
  830. <xsl:if test="namespace-uri(.)='http://nwalsh.com/docbook/xsl/template/1.0/param'">
  831. <xsl:text>&#xA;</xsl:text>
  832. <xsl:element name="xsl:with-param">
  833. <xsl:attribute name="name">
  834. <xsl:value-of select="local-name(.)"/>
  835. </xsl:attribute>
  836. <xsl:attribute name="select">
  837. <xsl:value-of select="."/>
  838. </xsl:attribute>
  839. </xsl:element>
  840. </xsl:if>
  841. </xsl:for-each>
  842. <xsl:text>&#xA;</xsl:text>
  843. </xsl:element>
  844. </xsl:element>
  845. </xsl:when>
  846. <xsl:otherwise>
  847. <xsl:message terminate="yes">
  848. <xsl:text>Force can only be used with named-templates.</xsl:text>
  849. </xsl:message>
  850. </xsl:otherwise>
  851. </xsl:choose>
  852. </xsl:when>
  853. <xsl:otherwise>
  854. <xsl:choose>
  855. <xsl:when test="local-name(.) = 'title'
  856. or local-name(.) = 'subtitle'
  857. or local-name(.) = 'titleabbrev'">
  858. <!-- the title, subtitle, and titleabbrev elements are special -->
  859. <xsl:element name="xsl:choose">
  860. <xsl:text>&#xA; </xsl:text>
  861. <xsl:element name="xsl:when">
  862. <xsl:attribute name="test">
  863. <xsl:value-of select="$docinfo"/>
  864. <xsl:text>/</xsl:text>
  865. <xsl:value-of select="name(.)"/>
  866. </xsl:attribute>
  867. <xsl:text>&#xA; </xsl:text>
  868. <xsl:element name="xsl:apply-templates">
  869. <xsl:attribute name="mode">
  870. <xsl:value-of select="$mode"/>
  871. </xsl:attribute>
  872. <xsl:attribute name="select">
  873. <xsl:value-of select="$docinfo"/>
  874. <xsl:text>/</xsl:text>
  875. <xsl:value-of select="name(.)"/>
  876. <xsl:if test="@t:predicate">
  877. <xsl:value-of select="@t:predicate"/>
  878. </xsl:if>
  879. </xsl:attribute>
  880. </xsl:element>
  881. <xsl:text>&#xA; </xsl:text>
  882. </xsl:element>
  883. <xsl:if test="$altinfo != ''">
  884. <xsl:text>&#xA; </xsl:text>
  885. <xsl:element name="xsl:when">
  886. <xsl:attribute name="test">
  887. <xsl:value-of select="$altinfo"/>
  888. <xsl:text>/</xsl:text>
  889. <xsl:value-of select="name(.)"/>
  890. </xsl:attribute>
  891. <xsl:text>&#xA; </xsl:text>
  892. <xsl:element name="xsl:apply-templates">
  893. <xsl:attribute name="mode">
  894. <xsl:value-of select="$mode"/>
  895. </xsl:attribute>
  896. <xsl:attribute name="select">
  897. <xsl:value-of select="$altinfo"/>
  898. <xsl:text>/</xsl:text>
  899. <xsl:value-of select="name(.)"/>
  900. <xsl:if test="@t:predicate">
  901. <xsl:value-of select="@t:predicate"/>
  902. </xsl:if>
  903. </xsl:attribute>
  904. </xsl:element>
  905. <xsl:text>&#xA; </xsl:text>
  906. </xsl:element>
  907. </xsl:if>
  908. <!-- info -->
  909. <xsl:text>&#xA; </xsl:text>
  910. <xsl:element name="xsl:when">
  911. <xsl:attribute name="test">
  912. <xsl:value-of select="'info'"/>
  913. <xsl:text>/</xsl:text>
  914. <xsl:value-of select="name(.)"/>
  915. </xsl:attribute>
  916. <xsl:text>&#xA; </xsl:text>
  917. <xsl:element name="xsl:apply-templates">
  918. <xsl:attribute name="mode">
  919. <xsl:value-of select="$mode"/>
  920. </xsl:attribute>
  921. <xsl:attribute name="select">
  922. <xsl:value-of select="'info'"/>
  923. <xsl:text>/</xsl:text>
  924. <xsl:value-of select="name(.)"/>
  925. <xsl:if test="@t:predicate">
  926. <xsl:value-of select="@t:predicate"/>
  927. </xsl:if>
  928. </xsl:attribute>
  929. </xsl:element>
  930. <xsl:text>&#xA; </xsl:text>
  931. </xsl:element>
  932. <xsl:text>&#xA; </xsl:text>
  933. <xsl:element name="xsl:when">
  934. <xsl:attribute name="test">
  935. <xsl:value-of select="name(.)"/>
  936. </xsl:attribute>
  937. <xsl:text>&#xA; </xsl:text>
  938. <xsl:element name="xsl:apply-templates">
  939. <xsl:attribute name="mode">
  940. <xsl:value-of select="$mode"/>
  941. </xsl:attribute>
  942. <xsl:attribute name="select">
  943. <xsl:value-of select="name(.)"/>
  944. <xsl:if test="@t:predicate">
  945. <xsl:value-of select="@t:predicate"/>
  946. </xsl:if>
  947. </xsl:attribute>
  948. </xsl:element>
  949. <xsl:text>&#xA; </xsl:text>
  950. </xsl:element>
  951. <xsl:text>&#xA; </xsl:text>
  952. </xsl:element>
  953. <xsl:text>&#xA;</xsl:text>
  954. </xsl:when>
  955. <xsl:otherwise>
  956. <!-- first take care of the $docinfo version -->
  957. <xsl:element name="xsl:apply-templates">
  958. <xsl:attribute name="mode">
  959. <xsl:value-of select="$mode"/>
  960. </xsl:attribute>
  961. <xsl:attribute name="select">
  962. <xsl:value-of select="$docinfo"/>
  963. <xsl:text>/</xsl:text>
  964. <xsl:value-of select="name(.)"/>
  965. <xsl:if test="@t:predicate">
  966. <xsl:value-of select="@t:predicate"/>
  967. </xsl:if>
  968. </xsl:attribute>
  969. </xsl:element>
  970. <!-- then take care of the $altinfo version -->
  971. <xsl:if test="$altinfo != ''">
  972. <xsl:text>&#xA; </xsl:text>
  973. <xsl:element name="xsl:apply-templates">
  974. <xsl:attribute name="mode">
  975. <xsl:value-of select="$mode"/>
  976. </xsl:attribute>
  977. <xsl:attribute name="select">
  978. <xsl:value-of select="$altinfo"/>
  979. <xsl:text>/</xsl:text>
  980. <xsl:value-of select="name(.)"/>
  981. <xsl:if test="@t:predicate">
  982. <xsl:value-of select="@t:predicate"/>
  983. </xsl:if>
  984. </xsl:attribute>
  985. </xsl:element>
  986. </xsl:if>
  987. <!-- info -->
  988. <xsl:text>&#xA; </xsl:text>
  989. <xsl:element name="xsl:apply-templates">
  990. <xsl:attribute name="mode">
  991. <xsl:value-of select="$mode"/>
  992. </xsl:attribute>
  993. <xsl:attribute name="select">
  994. <xsl:value-of select="'info'"/>
  995. <xsl:text>/</xsl:text>
  996. <xsl:value-of select="name(.)"/>
  997. <xsl:if test="@t:predicate">
  998. <xsl:value-of select="@t:predicate"/>
  999. </xsl:if>
  1000. </xsl:attribute>
  1001. </xsl:element>
  1002. </xsl:otherwise>
  1003. </xsl:choose>
  1004. </xsl:otherwise>
  1005. </xsl:choose>
  1006. </xsl:template>
  1007. <!-- ==================================================================== -->
  1008. <doc:template match="*" mode="titlepage.specialrules" xmlns=""
  1009. id="star_in_titlepage.specialrules">
  1010. <refpurpose>Create templates for special rules</refpurpose>
  1011. <refdescription>
  1012. <para>This template is called to process all of the descendants of the
  1013. <literal>t:titlepage-content</literal> element that require special
  1014. processing. At present, that's just <literal>t:or</literal> elements.
  1015. </para>
  1016. </refdescription>
  1017. </doc:template>
  1018. <xsl:template match="*" mode="titlepage.specialrules">
  1019. <xsl:variable name="side">
  1020. <xsl:choose>
  1021. <xsl:when test="ancestor::t:titlepage-content/@t:side">
  1022. <xsl:value-of select="ancestor::t:titlepage-content/@t:side"/>
  1023. </xsl:when>
  1024. <xsl:otherwise>recto</xsl:otherwise>
  1025. </xsl:choose>
  1026. </xsl:variable>
  1027. <xsl:variable name="mode">
  1028. <xsl:value-of select="ancestor::t:titlepage/@t:element"/>
  1029. <xsl:text>.titlepage.</xsl:text>
  1030. <xsl:value-of select="$side"/>
  1031. <xsl:text>.auto.mode</xsl:text>
  1032. </xsl:variable>
  1033. <xsl:choose>
  1034. <xsl:when test="name(.)='t:or'">
  1035. <xsl:apply-templates select="*" mode="titlepage.specialrules"/>
  1036. </xsl:when>
  1037. <xsl:otherwise>
  1038. <xsl:if test="*"><!-- does this element have children? -->
  1039. <xsl:text>&#xA;&#xA;</xsl:text>
  1040. <xsl:element name="xsl:template">
  1041. <xsl:attribute name="match">
  1042. <xsl:value-of select="name(.)"/>
  1043. </xsl:attribute>
  1044. <xsl:attribute name="mode">
  1045. <xsl:value-of select="$mode"/>
  1046. </xsl:attribute>
  1047. <xsl:apply-templates select="*" mode="titlepage.subrules"/>
  1048. <xsl:text>&#xA;</xsl:text>
  1049. </xsl:element>
  1050. </xsl:if>
  1051. </xsl:otherwise>
  1052. </xsl:choose>
  1053. </xsl:template>
  1054. <!-- ==================================================================== -->
  1055. <doc:template match="*" mode="titlepage.subrules" xmlns=""
  1056. id="star_in_titlepage.subrules">
  1057. <refpurpose>Create template for individual special rules</refpurpose>
  1058. <refdescription>
  1059. <para>This template is called to process the children of special
  1060. template elements.
  1061. </para>
  1062. </refdescription>
  1063. </doc:template>
  1064. <xsl:template match="*" mode="titlepage.subrules">
  1065. <xsl:variable name="side">
  1066. <xsl:choose>
  1067. <xsl:when test="ancestor::t:titlepage-content/@t:side">
  1068. <xsl:value-of select="ancestor::t:titlepage-content/@t:side"/>
  1069. </xsl:when>
  1070. <xsl:otherwise>recto</xsl:otherwise>
  1071. </xsl:choose>
  1072. </xsl:variable>
  1073. <xsl:variable name="mode">
  1074. <xsl:value-of select="ancestor::t:titlepage/@t:element"/>
  1075. <xsl:text>.titlepage.</xsl:text>
  1076. <xsl:value-of select="$side"/>
  1077. <xsl:text>.auto.mode</xsl:text>
  1078. </xsl:variable>
  1079. <xsl:element name="xsl:apply-templates">
  1080. <xsl:attribute name="select">
  1081. <xsl:value-of select="name(.)"/>
  1082. </xsl:attribute>
  1083. <xsl:attribute name="mode">
  1084. <xsl:value-of select="$mode"/>
  1085. </xsl:attribute>
  1086. </xsl:element>
  1087. </xsl:template>
  1088. <!-- ==================================================================== -->
  1089. <doc:template match="t:or" xmlns="" id="or">
  1090. <refpurpose>Process the t:or special rule</refpurpose>
  1091. <refdescription>
  1092. <para>This template processes t:or.</para>
  1093. </refdescription>
  1094. </doc:template>
  1095. <xsl:template match="t:or">
  1096. <xsl:variable name="side">
  1097. <xsl:choose>
  1098. <xsl:when test="ancestor::t:titlepage-content/@t:side">
  1099. <xsl:value-of select="ancestor::t:titlepage-content/@t:side"/>
  1100. </xsl:when>
  1101. <xsl:otherwise>recto</xsl:otherwise>
  1102. </xsl:choose>
  1103. </xsl:variable>
  1104. <xsl:variable name="mode">
  1105. <xsl:value-of select="ancestor::t:titlepage/@t:element"/>
  1106. <xsl:text>.titlepage.</xsl:text>
  1107. <xsl:value-of select="$side"/>
  1108. <xsl:text>.auto.mode</xsl:text>
  1109. </xsl:variable>
  1110. <xsl:text>&#xA; </xsl:text>
  1111. <xsl:element name="xsl:apply-templates">
  1112. <xsl:attribute name="select">
  1113. <xsl:call-template name="element-or-list"/>
  1114. </xsl:attribute>
  1115. <xsl:attribute name="mode">
  1116. <xsl:value-of select="$mode"/>
  1117. </xsl:attribute>
  1118. </xsl:element>
  1119. </xsl:template>
  1120. <!-- ==================================================================== -->
  1121. <doc:template match="t:or" mode="titlepage.subrules" xmlns=""
  1122. id="or_in_titlepage.subrules">
  1123. <refpurpose>Process the t:or special rule in
  1124. titlepage.subrules mode</refpurpose>
  1125. <refdescription>
  1126. <para>The titlepage.subrules mode doesn't apply to t:or, so just
  1127. reprocess this node in the normal mode.</para>
  1128. </refdescription>
  1129. </doc:template>
  1130. <xsl:template match="t:or" mode="titlepage.subrules">
  1131. <xsl:apply-templates select="."/><!-- use normal mode -->
  1132. </xsl:template>
  1133. <!-- ==================================================================== -->
  1134. <doc:template name="element-or-list" xmlns="">
  1135. <refpurpose>Construct the "or-list" used in the select attribute for
  1136. special rules.</refpurpose>
  1137. <refdescription>
  1138. <para>Walk through each of the children of t:or, producing the
  1139. text of the select attribute.</para>
  1140. </refdescription>
  1141. </doc:template>
  1142. <xsl:template name="element-or-list">
  1143. <xsl:param name="elements" select="*"/>
  1144. <xsl:param name="element.count" select="count($elements)"/>
  1145. <xsl:param name="count" select="1"/>
  1146. <xsl:param name="orlist"></xsl:param>
  1147. <xsl:choose>
  1148. <xsl:when test="$count>$element.count">
  1149. <xsl:value-of select="$orlist"/>
  1150. </xsl:when>
  1151. <xsl:otherwise>
  1152. <xsl:call-template name="element-or-list">
  1153. <xsl:with-param name="elements" select="$elements"/>
  1154. <xsl:with-param name="element.count" select="$element.count"/>
  1155. <xsl:with-param name="count" select="$count+1"/>
  1156. <xsl:with-param name="orlist">
  1157. <xsl:value-of select="$orlist"/>
  1158. <xsl:if test="not($orlist='')">|</xsl:if>
  1159. <xsl:value-of select="name($elements[position()=$count])"/>
  1160. </xsl:with-param>
  1161. </xsl:call-template>
  1162. </xsl:otherwise>
  1163. </xsl:choose>
  1164. </xsl:template>
  1165. <!-- ==================================================================== -->
  1166. </xsl:stylesheet>