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