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"
11 <!-- ********************************************************************
12 $Id: titlepage.xsl 7058 2007-07-17 13:59:29Z xmldoc $
13 ********************************************************************
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.
19 ******************************************************************** -->
21 <!-- ==================================================================== -->
23 <xsl:template match="/">
24 <xsl:text>
</xsl:text>
25 <xsl:apply-templates/>
26 <xsl:text>
</xsl:text>
29 <doc:reference xmlns="" xml:id="template">
30 <?dbhtml dir="template"?>
31 <?dbhtml filename="index.html"?>
33 <title>Titlepage Template Stylesheet Reference</title>
34 <releaseinfo role="meta">
35 $Id: titlepage.xsl 7058 2007-07-17 13:59:29Z xmldoc $
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
48 <!-- ==================================================================== -->
50 <xsl:preserve-space elements="*"/>
51 <xsl:strip-space elements="xsl:* t:*"/>
53 <!-- ==================================================================== -->
55 <doc:template match="t:templates" xmlns="" id="templates">
56 <refpurpose>Construct a stylesheet for the templates provided</refpurpose>
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>
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>
69 <xsl:template match="t:templates">
70 <xsl:element name="xsl:stylesheet">
72 <xsl:for-each select="document('')/xsl:stylesheet/namespace::exsl">
76 <xsl:attribute name="version">1.0</xsl:attribute>
77 <xsl:attribute name="exclude-result-prefixes">exsl</xsl:attribute>
79 <xsl:text>

</xsl:text>
81 <xsl:text> This stylesheet was created by </xsl:text>
82 <xsl:text>template/titlepage.xsl</xsl:text>
85 <xsl:if test="@t:base-stylesheet">
86 <xsl:text>

</xsl:text>
87 <xsl:element name="xsl:import">
88 <xsl:attribute name="href">
89 <xsl:value-of select="@t:base-stylesheet"/>
94 <xsl:apply-templates/>
96 <xsl:text>

</xsl:text>
100 <!-- ==================================================================== -->
102 <doc:template match="xsl:*" xmlns="" id="star">
103 <refpurpose>Copy xsl: elements straight through</refpurpose>
106 <para>This template simply copies the xsl: elements
107 straight through into the result tree.</para>
111 <xsl:template match="xsl:*">
112 <xsl:apply-templates select="." mode="copy"/>
115 <!-- ==================================================================== -->
117 <doc:template match="t:titlepage" xmlns="" id="titlepage">
118 <refpurpose>Create the templates necessary to construct a title page</refpurpose>
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.
128 <para>The <literal>t:titlepage</literal> element has three attributes:
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.
139 <varlistentry><term>wrapper</term>
140 <listitem><para>The entire title page can be wrapped with an element.
141 This attribute identifies that element.
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
154 <para>Any other attributes are copied through literally to the
155 wrapper element.</para>
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>
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>
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/>
173 <!-- output the title page template -->
174 <xsl:text>

</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>
180 <xsl:text>
 </xsl:text>
181 <xsl:element name="{@t:wrapper}">
182 <xsl:apply-templates select="@*" mode="copy.literal.atts"/>
183 <xsl:text>
 </xsl:text>
184 <xsl:element name="xsl:variable">
185 <xsl:attribute name="name">recto.content</xsl:attribute>
186 <xsl:text>
 </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>
193 <xsl:text>
 </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>
200 <xsl:text>
 </xsl:text>
202 <xsl:text>
 </xsl:text>
203 <xsl:element name="xsl:variable">
204 <xsl:attribute name="name">recto.elements.count</xsl:attribute>
205 <xsl:text>
 </xsl:text>
206 <xsl:element name="xsl:choose">
207 <xsl:text>
 </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>
214 <xsl:text>
 </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>
 </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>
223 <xsl:text>
 </xsl:text>
224 <xsl:element name="xsl:otherwise">
225 <xsl:text>1</xsl:text>
227 <xsl:text>
 </xsl:text>
229 <xsl:text>
 </xsl:text>
231 <xsl:text>
 </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>
 </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>
242 <xsl:text>
 </xsl:text>
244 <xsl:text>
 </xsl:text>
245 <xsl:element name="xsl:variable">
246 <xsl:attribute name="name">verso.content</xsl:attribute>
247 <xsl:text>
 </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>
254 <xsl:text>
 </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>
261 <xsl:text>
 </xsl:text>
263 <xsl:text>
 </xsl:text>
264 <xsl:element name="xsl:variable">
265 <xsl:attribute name="name">verso.elements.count</xsl:attribute>
266 <xsl:text>
 </xsl:text>
267 <xsl:element name="xsl:choose">
268 <xsl:text>
 </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>
275 <xsl:text>
 </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>
 </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>
284 <xsl:text>
 </xsl:text>
285 <xsl:element name="xsl:otherwise">
286 <xsl:text>1</xsl:text>
288 <xsl:text>
 </xsl:text>
290 <xsl:text>
 </xsl:text>
292 <xsl:text>
 </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>
 </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>
303 <xsl:text>
 </xsl:text>
305 <xsl:text>
 </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>
312 <xsl:text>
 </xsl:text>
314 <xsl:text>
</xsl:text>
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.)
323 <xsl:if test="not(../@t:base-stylesheet)">
324 <!-- output a default rule for the recto-modes elements -->
325 <xsl:text>

</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>
332 <xsl:text>
 </xsl:text>
333 <xsl:comment> if an element isn't found in this mode, </xsl:comment>
334 <xsl:text>
 </xsl:text>
335 <xsl:comment> try the generic titlepage.mode </xsl:comment>
336 <xsl:text>
 </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>
341 <xsl:text>
</xsl:text>
344 <!-- output a default rule for the verso-modes elements -->
345 <xsl:text>

</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>
352 <xsl:text>
 </xsl:text>
353 <xsl:comment> if an element isn't found in this mode, </xsl:comment>
354 <xsl:text>
 </xsl:text>
355 <xsl:comment> try the generic titlepage.mode </xsl:comment>
356 <xsl:text>
 </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>
361 <xsl:text>
</xsl:text>
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>

</xsl:text>
374 <xsl:element name="xsl:template">
375 <xsl:attribute name="match">
376 <xsl:value-of select="name(.)"/>
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>
384 <xsl:text>
</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>
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="."/>
400 <xsl:text>
</xsl:text>
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"/>
408 <xsl:for-each select="@*">
409 <xsl:if test="namespace-uri(.)='http://nwalsh.com/docbook/xsl/template/1.0/param'">
410 <xsl:text>
</xsl:text>
411 <xsl:element name="xsl:with-param">
412 <xsl:attribute name="name">
413 <xsl:value-of select="local-name(.)"/>
415 <xsl:attribute name="select">
416 <xsl:value-of select="."/>
421 <xsl:text>
</xsl:text>
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>
437 <xsl:text>
</xsl:text>
439 <xsl:text>
</xsl:text>
445 <doc:template match="@*" mode="copy.literal.atts" xmlns=""
446 id="attr_star_in_copy.literal.atts">
447 <refpurpose>Copy t:titlepage attributes</refpurpose>
450 <para>This template copies all of the <quote>other</quote> attributes
451 from a <literal>t:titlepage</literal> element onto the specified
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="."/>
465 <!-- ==================================================================== -->
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>
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>
475 <para>The <literal>t:titlepage-content</literal> element has two attributes:
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>
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>
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.
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>
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:
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>
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>
533 <para>In that case, you can put a <literal>t:or</literal> group inside
534 the <literal>authorgroup</literal> element:
537 <t:titlepage-contents side="recto">
538 <!-- other titlepage elements -->
546 <!-- other titlepage elements -->
547 </t:titlepage-contents>
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>
559 <xsl:template match="t:titlepage-content">
560 <xsl:variable name="side">
562 <xsl:when test="@t:side='recto' or @t:side='verso'">
563 <xsl:value-of select="@t:side"/>
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"/>
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>
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>
588 <xsl:text>

</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"/>
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::*)>0">
602 <xsl:element name="xsl:apply-templates">
603 <xsl:attribute name="mode">
604 <xsl:value-of select="$mode"/>
606 <xsl:attribute name="select">
607 <xsl:apply-templates mode="document.order"/>
613 <!-- otherwise, select each of the elements in the specified order -->
615 <xsl:apply-templates mode="stylesheet.order"/>
618 <xsl:text>
</xsl:text>
620 <xsl:apply-templates mode="titlepage.specialrules"/>
623 <!-- ==================================================================== -->
625 <doc:template match="t:titlepage-separator" id="titlepage-separator">
626 <refpurpose>Create templates for the separator</refpurpose>
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>
635 <xsl:template match="t:titlepage-separator">
636 <xsl:text>

</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>
643 <xsl:apply-templates mode="copy"/>
644 <xsl:text>
</xsl:text>
648 <!-- ==================================================================== -->
650 <doc:template match="t:titlepage-before" id="titlepage-before">
651 <refpurpose>Create templates for what precedes a title page</refpurpose>
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
660 <xsl:template match="t:titlepage-before">
661 <xsl:text>

</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"/>
669 <xsl:apply-templates mode="copy"/>
670 <xsl:text>
</xsl:text>
674 <!-- ==================================================================== -->
676 <doc:template match="*" mode="copy" xmlns="" id="star_in_copy">
677 <refpurpose>Copy elements</refpurpose>
680 <para>This template simply copies the elements that it applies to
681 straight through into the result tree.</para>
685 <xsl:template match="*" mode="copy">
686 <xsl:element name="{name(.)}">
687 <xsl:apply-templates select="@*" mode="copy"/>
688 <xsl:apply-templates mode="copy"/>
692 <!-- ==================================================================== -->
694 <doc:template match="@*" mode="copy" xmlns="" id="attr_star_in_copy">
695 <refpurpose>Copy attributes</refpurpose>
698 <para>This template simply copies the attributes that it applies to
699 straight through into the result tree.</para>
703 <xsl:template match="@*" mode="copy">
704 <xsl:attribute name="{name(.)}">
705 <xsl:value-of select="."/>
709 <!-- ==================================================================== -->
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>
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>
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.
725 <para>It also automatically calculates the name for the *info container
726 and handles elements that have historically had containers with different
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>
738 <xsl:variable name="altinfo">
740 <xsl:when test="ancestor::t:titlepage/@t:element='article'">
741 <xsl:text>artheader</xsl:text>
743 <xsl:when test="ancestor::t:titlepage/@t:element='qandaset'">
744 <xsl:text>blockinfo</xsl:text>
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>
758 <xsl:variable name="side">
760 <xsl:when test="ancestor::t:titlepage-content/@t:side">
761 <xsl:value-of select="ancestor::t:titlepage-content/@t:side"/>
764 <xsl:text>recto</xsl:text>
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>
776 <xsl:if test="preceding-sibling::*">
777 <xsl:text>|</xsl:text>
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"/>
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"/>
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"/>
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"/>
816 <!-- ==================================================================== -->
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>
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>
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.
832 <para>It also automatically calculates the name for the *info container
833 and handles elements that have historically had containers with different
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>
845 <xsl:variable name="altinfo">
847 <xsl:when test="ancestor::t:titlepage/@t:element='article'">
848 <xsl:text>artheader</xsl:text>
850 <xsl:when test="ancestor::t:titlepage/@t:element='qandaset'">
851 <xsl:text>blockinfo</xsl:text>
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>
865 <xsl:variable name="side">
867 <xsl:when test="ancestor::t:titlepage-content/@t:side">
868 <xsl:value-of select="ancestor::t:titlepage-content/@t:side"/>
870 <xsl:otherwise>recto</xsl:otherwise>
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>
881 <xsl:text>
 </xsl:text>
884 <xsl:when test="@t:force and @t:force != '0'">
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>
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="."/>
902 <xsl:text>
</xsl:text>
903 <xsl:element name="xsl:call-template">
904 <xsl:attribute name="name">
905 <xsl:value-of select="@t:named-template"/>
907 <xsl:for-each select="@*">
908 <xsl:if test="namespace-uri(.)='http://nwalsh.com/docbook/xsl/template/1.0/param'">
909 <xsl:text>
</xsl:text>
910 <xsl:element name="xsl:with-param">
911 <xsl:attribute name="name">
912 <xsl:value-of select="local-name(.)"/>
914 <xsl:attribute name="select">
915 <xsl:value-of select="."/>
920 <xsl:text>
</xsl:text>
925 <xsl:message terminate="yes">
926 <xsl:text>Force can only be used with named-templates.</xsl:text>
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>
 </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(.)"/>
946 <xsl:text>
 </xsl:text>
947 <xsl:element name="xsl:apply-templates">
948 <xsl:attribute name="mode">
949 <xsl:value-of select="$mode"/>
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"/>
960 <xsl:text>
 </xsl:text>
963 <xsl:if test="$altinfo != ''">
964 <xsl:text>
 </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(.)"/>
971 <xsl:text>
 </xsl:text>
972 <xsl:element name="xsl:apply-templates">
973 <xsl:attribute name="mode">
974 <xsl:value-of select="$mode"/>
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"/>
985 <xsl:text>
 </xsl:text>
990 <xsl:text>
 </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(.)"/>
997 <xsl:text>
 </xsl:text>
998 <xsl:element name="xsl:apply-templates">
999 <xsl:attribute name="mode">
1000 <xsl:value-of select="$mode"/>
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"/>
1011 <xsl:text>
 </xsl:text>
1014 <xsl:text>
 </xsl:text>
1015 <xsl:element name="xsl:when">
1016 <xsl:attribute name="test">
1017 <xsl:value-of select="name(.)"/>
1019 <xsl:text>
 </xsl:text>
1020 <xsl:element name="xsl:apply-templates">
1021 <xsl:attribute name="mode">
1022 <xsl:value-of select="$mode"/>
1024 <xsl:attribute name="select">
1025 <xsl:value-of select="name(.)"/>
1026 <xsl:if test="@t:predicate">
1027 <xsl:value-of select="@t:predicate"/>
1031 <xsl:text>
 </xsl:text>
1033 <xsl:text>
 </xsl:text>
1035 <xsl:text>
</xsl:text>
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"/>
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"/>
1054 <!-- then take care of the $altinfo version -->
1055 <xsl:if test="$altinfo != ''">
1056 <xsl:text>
 </xsl:text>
1057 <xsl:element name="xsl:apply-templates">
1058 <xsl:attribute name="mode">
1059 <xsl:value-of select="$mode"/>
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"/>
1073 <xsl:text>
 </xsl:text>
1074 <xsl:element name="xsl:apply-templates">
1075 <xsl:attribute name="mode">
1076 <xsl:value-of select="$mode"/>
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"/>
1093 <!-- ==================================================================== -->
1095 <doc:template match="*" mode="titlepage.specialrules" xmlns=""
1096 id="star_in_titlepage.specialrules">
1097 <refpurpose>Create templates for special rules</refpurpose>
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.
1107 <xsl:template match="*" mode="titlepage.specialrules">
1108 <xsl:variable name="side">
1110 <xsl:when test="ancestor::t:titlepage-content/@t:side">
1111 <xsl:value-of select="ancestor::t:titlepage-content/@t:side"/>
1113 <xsl:otherwise>recto</xsl:otherwise>
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>
1125 <xsl:when test="name(.)='t:or'">
1126 <xsl:apply-templates select="*" mode="titlepage.specialrules"/>
1129 <xsl:if test="*"><!-- does this element have children? -->
1130 <xsl:text>

</xsl:text>
1131 <xsl:element name="xsl:template">
1132 <xsl:attribute name="match">
1133 <xsl:value-of select="name(.)"/>
1135 <xsl:attribute name="mode">
1136 <xsl:value-of select="$mode"/>
1138 <xsl:apply-templates select="*" mode="titlepage.subrules"/>
1139 <xsl:text>
</xsl:text>
1146 <!-- ==================================================================== -->
1148 <doc:template match="*" mode="titlepage.subrules" xmlns=""
1149 id="star_in_titlepage.subrules">
1150 <refpurpose>Create template for individual special rules</refpurpose>
1153 <para>This template is called to process the children of special
1159 <xsl:template match="*" mode="titlepage.subrules">
1160 <xsl:variable name="side">
1162 <xsl:when test="ancestor::t:titlepage-content/@t:side">
1163 <xsl:value-of select="ancestor::t:titlepage-content/@t:side"/>
1165 <xsl:otherwise>recto</xsl:otherwise>
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>
1176 <xsl:element name="xsl:apply-templates">
1177 <xsl:attribute name="select">
1178 <xsl:value-of select="name(.)"/>
1180 <xsl:attribute name="mode">
1181 <xsl:value-of select="$mode"/>
1186 <!-- ==================================================================== -->
1188 <doc:template match="t:or" xmlns="" id="or">
1189 <refpurpose>Process the t:or special rule</refpurpose>
1192 <para>This template processes t:or.</para>
1196 <xsl:template match="t:or">
1197 <xsl:variable name="side">
1199 <xsl:when test="ancestor::t:titlepage-content/@t:side">
1200 <xsl:value-of select="ancestor::t:titlepage-content/@t:side"/>
1202 <xsl:otherwise>recto</xsl:otherwise>
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>
1213 <xsl:text>
 </xsl:text>
1214 <xsl:element name="xsl:apply-templates">
1215 <xsl:attribute name="select">
1216 <xsl:call-template name="element-or-list"/>
1218 <xsl:attribute name="mode">
1219 <xsl:value-of select="$mode"/>
1224 <!-- ==================================================================== -->
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>
1232 <para>The titlepage.subrules mode doesn't apply to t:or, so just
1233 reprocess this node in the normal mode.</para>
1237 <xsl:template match="t:or" mode="titlepage.subrules">
1238 <xsl:apply-templates select="."/><!-- use normal mode -->
1241 <!-- ==================================================================== -->
1243 <doc:template name="element-or-list" xmlns="">
1244 <refpurpose>Construct the "or-list" used in the select attribute for
1245 special rules.</refpurpose>
1248 <para>Walk through each of the children of t:or, producing the
1249 text of the select attribute.</para>
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>
1260 <xsl:when test="$count>$element.count">
1261 <xsl:value-of select="$orlist"/>
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])"/>
1273 </xsl:call-template>
1278 <!-- ==================================================================== -->