1<?xml version='1.0'?> 2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 3 xmlns:fo="http://www.w3.org/1999/XSL/Format" 4 xmlns:t="http://nwalsh.com/docbook/xsl/template/1.0" 5 xmlns:param="http://nwalsh.com/docbook/xsl/template/1.0/param" 6 xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" 7 exclude-result-prefixes="doc" 8 version='1.0'> 9 10<!-- ******************************************************************** 11 $Id$ 12 ******************************************************************** 13 14 This file is part of the XSL DocBook Stylesheet distribution. 15 See /README or http://nwalsh.com/docbook/xsl/ for copyright 16 and other information. 17 18 ******************************************************************** --> 19 20<!-- ==================================================================== --> 21 22<doc:reference xmlns=""> 23<referenceinfo> 24<releaseinfo role="meta"> 25$Id$ 26</releaseinfo> 27<author><surname>Walsh</surname> 28<firstname>Norman</firstname></author> 29<copyright><year>1999</year><year>2000</year> 30<holder>Norman Walsh</holder> 31</copyright> 32</referenceinfo> 33<title>Template Stylesheet Reference</title> 34 35<partintro> 36<section><title>Introduction</title> 37 38<para>This is technical reference documentation for the DocBook XSL 39Stylesheets; it documents (some of) the parameters, templates, and 40other elements of the stylesheets.</para> 41 42<para>This is not intended to be <quote>user</quote> documentation. 43It is provided for developers writing customization layers for the 44stylesheets, and for anyone who's interested in <quote>how it 45works</quote>.</para> 46 47<para>Although I am trying to be thorough, this documentation is known 48to be incomplete. Don't forget to read the source, too :-)</para> 49</section> 50</partintro> 51 52</doc:reference> 53 54<!-- ==================================================================== --> 55 56<xsl:preserve-space elements="*"/> 57<xsl:strip-space elements="xsl:* t:*"/> 58 59<!-- ==================================================================== --> 60 61<doc:template match="t:templates" xmlns=""> 62<refpurpose>Construct a stylesheet for the templates provided</refpurpose> 63 64<refdescription> 65<para>The <literal>t:templates</literal> element is the root of a 66set of templates. This template creates an appropriate 67<literal>xsl:stylesheet</literal> for the templates.</para> 68 69<para>If the <literal>t:templates</literal> element has a 70<literal>base-stylesheet</literal> attribute, an 71<literal>xsl:import</literal> statement is constructed for it.</para> 72</refdescription> 73</doc:template> 74 75<xsl:template match="t:templates"> 76 <xsl:element name="xsl:stylesheet"> 77 <xsl:attribute name="version">1.0</xsl:attribute> 78 79 <xsl:text>

</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:text>do not edit it by hand. </xsl:text> 84 </xsl:comment> 85 86 <xsl:if test="@base-stylesheet"> 87 <xsl:text>

</xsl:text> 88 <xsl:element name="xsl:import"> 89 <xsl:attribute name="href"> 90 <xsl:value-of select="@base-stylesheet"/> 91 </xsl:attribute> 92 </xsl:element> 93 </xsl:if> 94 95 <xsl:apply-templates/> 96 97 <xsl:text>

</xsl:text> 98 </xsl:element> 99</xsl:template> 100 101<!-- ==================================================================== --> 102 103<doc:template match="xsl:*" xmlns=""> 104<refpurpose>Copy xsl: elements straight through</refpurpose> 105 106<refdescription> 107<para>This template simply copies the xsl: elements 108straight through into the result tree.</para> 109</refdescription> 110</doc:template> 111 112<xsl:template match="xsl:*"> 113 <xsl:apply-templates select="." mode="copy"/> 114</xsl:template> 115 116<!-- ==================================================================== --> 117 118<doc:template match="t:titlepage" xmlns=""> 119<refpurpose>Create the templates necessary to construct a title page</refpurpose> 120 121<refdescription> 122<para>The <literal>t:titlepage</literal> element creates a set of 123templates for processing the titlepage for an element. The 124<quote>root</quote> of this template set is the template named 125<quote><literal>wrapper.titlepage</literal></quote>. That is the 126template that should be called to generate the title page. 127</para> 128 129<para>The <literal>t:titlepage</literal> element has three attributes: 130 131<variablelist> 132<varlistentry><term>element</term> 133<listitem><para>The name of the source document element for which 134these templates apply. In other words, to make a title page for the 135<sgmltag>article</sgmltag> element, set the 136<sgmltag class="attribute">element</sgmltag> attribute to 137<quote><literal>article</literal></quote>. This attribute is required. 138</para></listitem> 139</varlistentry> 140<varlistentry><term>wrapper</term> 141<listitem><para>The entire title page can be wrapped with an element. 142This attribute identifies that element. 143</para></listitem> 144</varlistentry> 145<varlistentry><term>class</term> 146<listitem><para>If the <sgmltag class="attribute">class</sgmltag> attribute 147is set, a <sgmltag class="attribute">class</sgmltag> attribute with this 148value will be added to the wrapper element that surrounds the entire 149title page. 150</para></listitem> 151</varlistentry> 152</variablelist> 153</para> 154 155<para>Any other attributes are copied through literally to the 156wrapper element.</para> 157 158<para>The content of a <literal>t:titlepage</literal> is one or 159more <literal>t:titlepage-content</literal>, 160<literal>t:titlepage-separator</literal>, and 161<literal>t:titlepage-before</literal> elements.</para> 162 163<para>Each of these elements may be provided for the <quote>recto</quote> 164and <quote>verso</quote> sides of the title page.</para> 165 166</refdescription> 167</doc:template> 168 169<xsl:template match="t:titlepage"> 170 <!-- process the children to make the templates for the content, 171 separator, and before elements --> 172 <xsl:apply-templates/> 173 174 <!-- output the title page template --> 175 <xsl:text>

</xsl:text> 176 <xsl:element name="xsl:template"> 177 <xsl:attribute name="name"> 178 <xsl:value-of select="@element"/> 179 <xsl:text>.titlepage</xsl:text> 180 </xsl:attribute> 181 <xsl:text>
 </xsl:text> 182 <xsl:element name="{@wrapper}"> 183 <xsl:apply-templates select="@*" mode="copy.literal.atts"/> 184 <xsl:text>
 </xsl:text> 185 <xsl:element name="xsl:call-template"> 186 <xsl:attribute name="name"> 187 <xsl:value-of select="@element"/> 188 <xsl:text>.titlepage.before.recto</xsl:text> 189 </xsl:attribute> 190 </xsl:element> 191 <xsl:text>
 </xsl:text> 192 <xsl:element name="xsl:call-template"> 193 <xsl:attribute name="name"> 194 <xsl:value-of select="@element"/> 195 <xsl:text>.titlepage.recto</xsl:text> 196 </xsl:attribute> 197 </xsl:element> 198 <xsl:text>
 </xsl:text> 199 <xsl:element name="xsl:call-template"> 200 <xsl:attribute name="name"> 201 <xsl:value-of select="@element"/> 202 <xsl:text>.titlepage.before.verso</xsl:text> 203 </xsl:attribute> 204 </xsl:element> 205 <xsl:text>
 </xsl:text> 206 <xsl:element name="xsl:call-template"> 207 <xsl:attribute name="name"> 208 <xsl:value-of select="@element"/> 209 <xsl:text>.titlepage.verso</xsl:text> 210 </xsl:attribute> 211 </xsl:element> 212 <xsl:text>
 </xsl:text> 213 <xsl:element name="xsl:call-template"> 214 <xsl:attribute name="name"> 215 <xsl:value-of select="@element"/> 216 <xsl:text>.titlepage.separator</xsl:text> 217 </xsl:attribute> 218 </xsl:element> 219 <xsl:text>
 </xsl:text> 220 </xsl:element> 221 <xsl:text>
</xsl:text> 222 </xsl:element> 223 224 <!-- If we're not importing a base stylesheet, output a default rule 225 for the recto- and verso-mode elements. (If we are importing a 226 base stylesheet, don't do this since the *-rules in the stylesheet 227 will totally override the rules that would otherwise be imported.) 228 --> 229 230 <xsl:if test="not(../@base-stylesheet)"> 231 <!-- output a default rule for the recto-modes elements --> 232 <xsl:text>

</xsl:text> 233 <xsl:element name="xsl:template"> 234 <xsl:attribute name="match">*</xsl:attribute> 235 <xsl:attribute name="mode"> 236 <xsl:value-of select="@element"/> 237 <xsl:text>.titlepage.recto.mode</xsl:text> 238 </xsl:attribute> 239 <xsl:text>
 </xsl:text> 240 <xsl:comment> if an element isn't found in this mode, </xsl:comment> 241 <xsl:text>
 </xsl:text> 242 <xsl:comment> try the generic titlepage.mode </xsl:comment> 243 <xsl:text>
 </xsl:text> 244 <xsl:element name="xsl:apply-templates"> 245 <xsl:attribute name="select">.</xsl:attribute> 246 <xsl:attribute name="mode">titlepage.mode</xsl:attribute> 247 </xsl:element> 248 <xsl:text>
</xsl:text> 249 </xsl:element> 250 251 <!-- output a default rule for the verso-modes elements --> 252 <xsl:text>

</xsl:text> 253 <xsl:element name="xsl:template"> 254 <xsl:attribute name="match">*</xsl:attribute> 255 <xsl:attribute name="mode"> 256 <xsl:value-of select="@element"/> 257 <xsl:text>.titlepage.verso.mode</xsl:text> 258 </xsl:attribute> 259 <xsl:text>
 </xsl:text> 260 <xsl:comment> if an element isn't found in this mode, </xsl:comment> 261 <xsl:text>
 </xsl:text> 262 <xsl:comment> try the generic titlepage.mode </xsl:comment> 263 <xsl:text>
 </xsl:text> 264 <xsl:element name="xsl:apply-templates"> 265 <xsl:attribute name="select">.</xsl:attribute> 266 <xsl:attribute name="mode">titlepage.mode</xsl:attribute> 267 </xsl:element> 268 <xsl:text>
</xsl:text> 269 </xsl:element> 270 </xsl:if> 271 272 <!-- output default templates for each of the elements listed in --> 273 <!-- the titlepage-content. If a template is suppressed or forced --> 274 <!-- to be off, or has already been output, don't output it. --> 275 <xsl:for-each select="t:titlepage-content/*"> 276 <xsl:variable name="thisnode" select="."/> 277 <xsl:if test="(not(@suppress-template) or @suppress-template='0') 278 and (not(@force) or @force='0') 279 and (not(preceding-sibling::*[name(.)=name($thisnode)]))"> 280 <xsl:text>

</xsl:text> 281 <xsl:element name="xsl:template"> 282 <xsl:attribute name="match"> 283 <xsl:value-of select="name(.)"/> 284 </xsl:attribute> 285 <xsl:attribute name="mode"> 286 <xsl:value-of select="../../@element"/> 287 <xsl:text>.titlepage.</xsl:text> 288 <xsl:value-of select="../@side"/> 289 <xsl:text>.auto.mode</xsl:text> 290 </xsl:attribute> 291 <xsl:text>
</xsl:text> 292 <xsl:element name="{../../@wrapper}"> 293 <xsl:attribute name="xsl:use-attribute-sets"> 294 <xsl:value-of select="../../@element"/> 295 <xsl:text>.titlepage.</xsl:text> 296 <xsl:value-of select="../@side"/> 297 <xsl:text>.style</xsl:text> 298 </xsl:attribute> 299 <xsl:for-each select="@*"> 300 <xsl:if test="namespace-uri(.)='http://www.w3.org/1999/XSL/Format'"> 301 <xsl:attribute name="{local-name(.)}"> 302 <xsl:value-of select="."/> 303 </xsl:attribute> 304 </xsl:if> 305 </xsl:for-each> 306 <xsl:text>
</xsl:text> 307 308 <xsl:choose> 309 <xsl:when test="@named-template"> 310 <xsl:element name="xsl:call-template"> 311 <xsl:attribute name="name"> 312 <xsl:value-of select="@named-template"/> 313 </xsl:attribute> 314 <xsl:for-each select="@*"> 315 <xsl:if test="namespace-uri(.)='http://nwalsh.com/docbook/xsl/template/1.0/param'"> 316 <xsl:text>
</xsl:text> 317 <xsl:element name="xsl:with-param"> 318 <xsl:attribute name="name"> 319 <xsl:value-of select="local-name(.)"/> 320 </xsl:attribute> 321 <xsl:attribute name="select"> 322 <xsl:value-of select="."/> 323 </xsl:attribute> 324 </xsl:element> 325 </xsl:if> 326 </xsl:for-each> 327 <xsl:text>
</xsl:text> 328 </xsl:element> 329 </xsl:when> 330 <xsl:otherwise> 331 <xsl:element name="xsl:apply-templates"> 332 <xsl:attribute name="select">.</xsl:attribute> 333 <xsl:attribute name="mode"> 334 <xsl:value-of select="../../@element"/> 335 <xsl:text>.titlepage.</xsl:text> 336 <xsl:value-of select="../@side"/> 337 <xsl:text>.mode</xsl:text> 338 </xsl:attribute> 339 </xsl:element> 340 </xsl:otherwise> 341 </xsl:choose> 342 343 <xsl:text>
</xsl:text> 344 </xsl:element> 345 <xsl:text>
</xsl:text> 346 </xsl:element> 347 </xsl:if> 348 </xsl:for-each> 349</xsl:template> 350 351<doc:template match="@*" mode="copy.literal.atts" xmlns=""> 352<refpurpose>Copy t:titlepage attributes</refpurpose> 353 354<refdescription> 355<para>This template copies all of the <quote>other</quote> attributes 356from a <literal>t:titlepage</literal> element onto the specified 357wrapper.</para> 358</refdescription> 359</doc:template> 360 361<xsl:template match="@*" mode="copy.literal.atts"> 362 <xsl:choose> 363 <xsl:when test="name(.) = 'element'"></xsl:when> 364 <xsl:when test="name(.) = 'wrapper'"></xsl:when> 365 <xsl:otherwise> 366 <xsl:attribute name="{name(.)}"> 367 <xsl:value-of select="."/> 368 </xsl:attribute> 369 </xsl:otherwise> 370 </xsl:choose> 371</xsl:template> 372 373<!-- ==================================================================== --> 374 375<doc:template match="t:titlepage-content"> 376<refpurpose>Create templates for the content of one side of a title page</refpurpose> 377 378<refdescription> 379<para>The title page content, that is, the elements from the source 380document that are rendered on the title page, can be controlled independently 381for the recto and verso sides of the title page.</para> 382 383<para>The <literal>t:titlepage-content</literal> element has two attributes: 384 385<variablelist> 386<varlistentry><term>side</term> 387<listitem><para>Identifies the side of the page to which this title 388page content applies. The 389<sgmltag class="attribute">side</sgmltag> attribute is required and 390must be set to either 391<quote><literal>recto</literal></quote> or 392<quote><literal>verso</literal></quote>. In addition, you must specify 393exactly one <literal>t:titlepage-content</literal> for each side 394within each <literal>t:titlepage</literal>.</para> 395</listitem> 396</varlistentry> 397<varlistentry><term>order</term> 398<listitem><para>Indicates how the order of the elements presented on 399the title page is determined. If the 400<sgmltag class="attribute">order</sgmltag> is 401<quote><literal>document</literal></quote>, the elements are presented 402in document order. Otherwise (if the 403<sgmltag class="attribute">order</sgmltag> is 404<quote><literal>stylesheet</literal></quote>), the elements are presented 405in the order that they appear in the template (and consequently in 406the stylesheet).</para> 407</listitem> 408</varlistentry> 409</variablelist> 410</para> 411 412<para>The content of a <literal>t:titlepage-content</literal> element is 413a list of element names. These names should be unqualified. They identify 414the elements in the source document that should appear on the title page. 415</para> 416 417<para>Each element may have a single attribute: 418<sgmltag class="attribute">predicate</sgmltag>. The value of this 419attribute is used as a predicate for the expression that matches 420the element on which it occurs.</para> 421 422<para>In other words, to put only the first three authors on the 423recto-side of a title 424page, you could specify: 425 426<screen><![CDATA[ 427 <t:titlepage-contents side="recto"> 428 <!-- other titlepage elements --> 429 <author predicate="[count(previous-sibling::author)<2]"/> 430 <!-- other titlepage elements --> 431 </t:titlepage-contents> 432]]></screen> 433</para> 434 435<para>Usually, the elements so named are empty. But it is possible to 436make one level of selection within them. Suppose that you want to 437process <literal>authorgroup</literal> elements on the title page, but 438you want to select only proper authors, editors, or corporate authors, 439not collaborators or other credited authors.</para> 440 441<para>In that case, you can put a <literal>t:or</literal> group inside 442the <literal>authorgroup</literal> element: 443 444<screen><![CDATA[ 445 <t:titlepage-contents side="recto"> 446 <!-- other titlepage elements --> 447 <authorgroup> 448 <t:or> 449 <author/> 450 <editor/> 451 <corpauthor/> 452 </t:or> 453 </authorgroup> 454 <!-- other titlepage elements --> 455 </t:titlepage-contents> 456]]></screen> 457</para> 458 459<para>This will have the effect of automatically generating a template 460for processing <literal>authorgroup</literal>s in the title page mode, 461selecting only the specified children. If you need more complex processing, 462you'll have to construct the templates by hand.</para> 463 464</refdescription> 465</doc:template> 466 467<xsl:template match="t:titlepage-content"> 468 <xsl:variable name="side"> 469 <xsl:choose> 470 <xsl:when test="@side='recto' or @side='verso'"> 471 <xsl:value-of select="@side"/> 472 </xsl:when> 473 <xsl:when test="@side"> 474 <xsl:message terminate="yes"> 475 <xsl:text>Illegal value specified for @side </xsl:text> 476 <xsl:text>on t:titlepage-content: </xsl:text> 477 <xsl:value-of select="@side"/> 478 </xsl:message> 479 </xsl:when> 480 <xsl:otherwise> 481 <xsl:message terminate="yes"> 482 <xsl:text>The @side attribute is required on </xsl:text> 483 <xsl:text>t:titlepage-content.</xsl:text> 484 </xsl:message> 485 </xsl:otherwise> 486 </xsl:choose> 487 </xsl:variable> 488 489 <xsl:variable name="mode"> 490 <xsl:value-of select="../@element"/> 491 <xsl:text>.titlepage.</xsl:text> 492 <xsl:value-of select="$side"/> 493 <xsl:text>.auto.mode</xsl:text> 494 </xsl:variable> 495 496 <xsl:text>

</xsl:text> 497 <xsl:element name="xsl:template"> 498 <xsl:attribute name="name"> 499 <xsl:value-of select="../@element"/> 500 <xsl:text>.titlepage.</xsl:text> 501 <xsl:value-of select="$side"/> 502 </xsl:attribute> 503 504 <xsl:choose> 505 <!-- if document order is selected, make a huge select statement 506 on a single xsl:apply-templates to pick out the right elements 507 for the title page. --> 508 <xsl:when test="@order='document'"> 509 <xsl:if test="count(child::*)>0"> 510 <xsl:element name="xsl:apply-templates"> 511 <xsl:attribute name="mode"> 512 <xsl:value-of select="$mode"/> 513 </xsl:attribute> 514 <xsl:attribute name="select"> 515 <xsl:apply-templates mode="document.order"/> 516 </xsl:attribute> 517 </xsl:element> 518 </xsl:if> 519 </xsl:when> 520 521 <!-- otherwise, select each of the elements in the specified order --> 522 <xsl:otherwise> 523 <xsl:apply-templates mode="stylesheet.order"/> 524 </xsl:otherwise> 525 </xsl:choose> 526 <xsl:text>
</xsl:text> 527 </xsl:element> 528 <xsl:apply-templates mode="titlepage.specialrules"/> 529</xsl:template> 530 531<!-- ==================================================================== --> 532 533<doc:template match="t:titlepage-separator"> 534<refpurpose>Create templates for the separator</refpurpose> 535 536<refdescription> 537<para>The title page is separated from the content which follows it by 538the markup specified in the <literal>t:titlepage-separator</literal> 539element.</para> 540</refdescription> 541</doc:template> 542 543<xsl:template match="t:titlepage-separator"> 544 <xsl:text>

</xsl:text> 545 <xsl:element name="xsl:template"> 546 <xsl:attribute name="name"> 547 <xsl:value-of select="../@element"/> 548 <xsl:text>.titlepage.separator</xsl:text> 549 </xsl:attribute> 550 551 <xsl:apply-templates mode="copy"/> 552 <xsl:text>
</xsl:text> 553 </xsl:element> 554</xsl:template> 555 556<!-- ==================================================================== --> 557 558<doc:template match="t:titlepage-before"> 559<refpurpose>Create templates for what precedes a title page</refpurpose> 560 561<refdescription> 562<para>Each side of the title page is preceded by the markup specified 563in the <literal>t:titlepage-before</literal> element for that 564side.</para> 565</refdescription> 566</doc:template> 567 568<xsl:template match="t:titlepage-before"> 569 <xsl:text>

</xsl:text> 570 <xsl:element name="xsl:template"> 571 <xsl:attribute name="name"> 572 <xsl:value-of select="../@element"/> 573 <xsl:text>.titlepage.before.</xsl:text> 574 <xsl:value-of select="@side"/> 575 </xsl:attribute> 576 577 <xsl:apply-templates mode="copy"/> 578 <xsl:text>
</xsl:text> 579 </xsl:element> 580</xsl:template> 581 582<!-- ==================================================================== --> 583 584<doc:template match="*" mode="copy" xmlns=""> 585<refpurpose>Copy elements</refpurpose> 586 587<refdescription> 588<para>This template simply copies the elements that it applies to 589straight through into the result tree.</para> 590</refdescription> 591</doc:template> 592 593<xsl:template match="*" mode="copy"> 594 <xsl:element name="{name(.)}"> 595 <xsl:apply-templates select="@*" mode="copy"/> 596 <xsl:apply-templates mode="copy"/> 597 </xsl:element> 598</xsl:template> 599 600<!-- ==================================================================== --> 601 602<doc:template match="@*" mode="copy" xmlns=""> 603<refpurpose>Copy attributes</refpurpose> 604 605<refdescription> 606<para>This template simply copies the attributes that it applies to 607straight through into the result tree.</para> 608</refdescription> 609</doc:template> 610 611<xsl:template match="@*" mode="copy"> 612 <xsl:attribute name="{name(.)}"> 613 <xsl:value-of select="."/> 614 </xsl:attribute> 615</xsl:template> 616 617<!-- ==================================================================== --> 618 619<doc:template match="*" mode="document.order" xmlns=""> 620<refpurpose>Create rules to process titlepage elements in document order</refpurpose> 621 622<refdescription> 623<para>This template is called to process all of the children of the 624<literal>t:titlepage-content</literal> element. It creates the hairy 625select expression necessary to process each of those elements in 626the title page.</para> 627 628<para>Note that this template automatically handles the case where 629some DocBook elements, like title and subtitle, can occur both inside 630the *info elements where metadata is usually stored and outside. 631</para> 632 633<para>It also automatically calculates the name for the *info container 634and handles elements that have historically had containers with different 635names.</para> 636 637</refdescription> 638</doc:template> 639 640<xsl:template match="*" mode="document.order"> 641 <xsl:variable name="docinfo"> 642 <xsl:value-of select="ancestor::t:titlepage/@element"/> 643 <xsl:text>info</xsl:text> 644 </xsl:variable> 645 646 <xsl:variable name="altinfo"> 647 <xsl:choose> 648 <xsl:when test="ancestor::t:titlepage/@element='article'"> 649 <xsl:text>artheader</xsl:text> 650 </xsl:when> 651 <xsl:when test="ancestor::t:titlepage/@element='section'"></xsl:when> 652 <xsl:when test="ancestor::t:titlepage/@element='sect1'"></xsl:when> 653 <xsl:when test="ancestor::t:titlepage/@element='sect2'"></xsl:when> 654 <xsl:when test="ancestor::t:titlepage/@element='sect3'"></xsl:when> 655 <xsl:when test="ancestor::t:titlepage/@element='sect4'"></xsl:when> 656 <xsl:when test="ancestor::t:titlepage/@element='sect5'"></xsl:when> 657 <xsl:when test="ancestor::t:titlepage/@element='book'"></xsl:when> 658 <xsl:when test="ancestor::t:titlepage/@element='set'"></xsl:when> 659 <xsl:otherwise>docinfo</xsl:otherwise> 660 </xsl:choose> 661 </xsl:variable> 662 663 <xsl:variable name="side"> 664 <xsl:choose> 665 <xsl:when test="ancestor::t:titlepage-content/@side"> 666 <xsl:value-of select="ancestor::t:titlepage-content/@side"/> 667 </xsl:when> 668 <xsl:otherwise> 669 <xsl:text>recto</xsl:text> 670 </xsl:otherwise> 671 </xsl:choose> 672 </xsl:variable> 673 674 <xsl:variable name="mode"> 675 <xsl:value-of select="ancestor::t:titlepage/@element"/> 676 <xsl:text>.titlepage.</xsl:text> 677 <xsl:value-of select="$side"/> 678 <xsl:text>.auto.mode</xsl:text> 679 </xsl:variable> 680 681 <xsl:if test="preceding-sibling::*"> 682 <xsl:text>|</xsl:text> 683 </xsl:if> 684 685 <xsl:value-of select="$docinfo"/> 686 <xsl:text>/</xsl:text> 687 <xsl:value-of select="name(.)"/> 688 <xsl:if test="@predicate"> 689 <xsl:value-of select="@predicate"/> 690 </xsl:if> 691 692 <xsl:if test="$altinfo != ''"> 693 <xsl:text>|</xsl:text> 694 <xsl:value-of select="$altinfo"/> 695 <xsl:text>/</xsl:text> 696 <xsl:value-of select="name(.)"/> 697 <xsl:if test="@predicate"> 698 <xsl:value-of select="@predicate"/> 699 </xsl:if> 700 </xsl:if> 701 702 <xsl:if test="local-name(.) = 'title' 703 or local-name(.) = 'subtitle' 704 or local-name(.) = 'titleabbrev'"> 705 <xsl:text>|</xsl:text> 706 <xsl:value-of select="name(.)"/> 707 <xsl:if test="@predicate"> 708 <xsl:value-of select="@predicate"/> 709 </xsl:if> 710 </xsl:if> 711</xsl:template> 712 713<!-- ==================================================================== --> 714 715<doc:template match="*" mode="document.order" xmlns=""> 716<refpurpose>Create rules to process titlepage elements in stylesheet order</refpurpose> 717 718<refdescription> 719<para>This template is called to process all of the children of the 720<literal>t:titlepage-content</literal> element. It creates the set 721of <literal>xsl:apply-templates</literal> elements necessary 722process each of those elements in the title page.</para> 723 724<para>Note that this template automatically handles the case where 725some DocBook elements, like title and subtitle, can occur both inside 726the *info elements where metadata is usually stored and outside. 727</para> 728 729<para>It also automatically calculates the name for the *info container 730and handles elements that have historically had containers with different 731names.</para> 732 733</refdescription> 734</doc:template> 735 736<xsl:template match="*" mode="stylesheet.order"> 737 <xsl:variable name="docinfo"> 738 <xsl:value-of select="ancestor::t:titlepage/@element"/> 739 <xsl:text>info</xsl:text> 740 </xsl:variable> 741 742 <xsl:variable name="altinfo"> 743 <xsl:choose> 744 <xsl:when test="ancestor::t:titlepage/@element='article'"> 745 <xsl:text>artheader</xsl:text> 746 </xsl:when> 747 <xsl:when test="ancestor::t:titlepage/@element='section'"></xsl:when> 748 <xsl:when test="ancestor::t:titlepage/@element='sect1'"></xsl:when> 749 <xsl:when test="ancestor::t:titlepage/@element='sect2'"></xsl:when> 750 <xsl:when test="ancestor::t:titlepage/@element='sect3'"></xsl:when> 751 <xsl:when test="ancestor::t:titlepage/@element='sect4'"></xsl:when> 752 <xsl:when test="ancestor::t:titlepage/@element='sect5'"></xsl:when> 753 <xsl:when test="ancestor::t:titlepage/@element='book'"></xsl:when> 754 <xsl:when test="ancestor::t:titlepage/@element='set'"></xsl:when> 755 <xsl:otherwise>docinfo</xsl:otherwise> 756 </xsl:choose> 757 </xsl:variable> 758 759 <xsl:variable name="side"> 760 <xsl:choose> 761 <xsl:when test="ancestor::t:titlepage-content/@side"> 762 <xsl:value-of select="ancestor::t:titlepage-content/@side"/> 763 </xsl:when> 764 <xsl:otherwise>recto</xsl:otherwise> 765 </xsl:choose> 766 </xsl:variable> 767 768 <xsl:variable name="mode"> 769 <xsl:value-of select="ancestor::t:titlepage/@element"/> 770 <xsl:text>.titlepage.</xsl:text> 771 <xsl:value-of select="$side"/> 772 <xsl:text>.auto.mode</xsl:text> 773 </xsl:variable> 774 775 <xsl:text>
 </xsl:text> 776 777 <xsl:choose> 778 <xsl:when test="@force and @force != '0'"> 779 <xsl:choose> 780 <xsl:when test="@named-template"> 781 <xsl:element name="{../../@wrapper}"> 782 <xsl:attribute name="xsl:use-attribute-sets"> 783 <xsl:value-of select="../../@element"/> 784 <xsl:text>.titlepage.</xsl:text> 785 <xsl:value-of select="../@side"/> 786 <xsl:text>.style</xsl:text> 787 </xsl:attribute> 788 <xsl:for-each select="@*"> 789 <xsl:if test="namespace-uri(.)='http://www.w3.org/1999/XSL/Format'"> 790 <xsl:attribute name="{local-name(.)}"> 791 <xsl:value-of select="."/> 792 </xsl:attribute> 793 </xsl:if> 794 </xsl:for-each> 795 <xsl:text>
</xsl:text> 796 <xsl:element name="xsl:call-template"> 797 <xsl:attribute name="name"> 798 <xsl:value-of select="@named-template"/> 799 </xsl:attribute> 800 <xsl:for-each select="@*"> 801 <xsl:if test="namespace-uri(.)='http://nwalsh.com/docbook/xsl/template/1.0/param'"> 802 <xsl:text>
</xsl:text> 803 <xsl:element name="xsl:with-param"> 804 <xsl:attribute name="name"> 805 <xsl:value-of select="local-name(.)"/> 806 </xsl:attribute> 807 <xsl:attribute name="select"> 808 <xsl:value-of select="."/> 809 </xsl:attribute> 810 </xsl:element> 811 </xsl:if> 812 </xsl:for-each> 813 <xsl:text>
</xsl:text> 814 </xsl:element> 815 </xsl:element> 816 </xsl:when> 817 <xsl:otherwise> 818 <xsl:message terminate="yes"> 819 <xsl:text>Force can only be used with named-templates.</xsl:text> 820 </xsl:message> 821 </xsl:otherwise> 822 </xsl:choose> 823 </xsl:when> 824 <xsl:otherwise> 825 826 <xsl:choose> 827 <xsl:when test="local-name(.) = 'title' 828 or local-name(.) = 'subtitle' 829 or local-name(.) = 'titleabbrev'"> 830 <!-- the title, subtitle, and titleabbrev elements are special --> 831 <xsl:element name="xsl:choose"> 832 <xsl:text>
 </xsl:text> 833 <xsl:element name="xsl:when"> 834 <xsl:attribute name="test"> 835 <xsl:value-of select="$docinfo"/> 836 <xsl:text>/</xsl:text> 837 <xsl:value-of select="name(.)"/> 838 </xsl:attribute> 839 <xsl:text>
 </xsl:text> 840 <xsl:element name="xsl:apply-templates"> 841 <xsl:attribute name="mode"> 842 <xsl:value-of select="$mode"/> 843 </xsl:attribute> 844 <xsl:attribute name="select"> 845 <xsl:value-of select="$docinfo"/> 846 <xsl:text>/</xsl:text> 847 <xsl:value-of select="name(.)"/> 848 <xsl:if test="@predicate"> 849 <xsl:value-of select="@predicate"/> 850 </xsl:if> 851 </xsl:attribute> 852 </xsl:element> 853 <xsl:text>
 </xsl:text> 854 </xsl:element> 855 856 <xsl:if test="$altinfo != ''"> 857 <xsl:text>
 </xsl:text> 858 <xsl:element name="xsl:when"> 859 <xsl:attribute name="test"> 860 <xsl:value-of select="$altinfo"/> 861 <xsl:text>/</xsl:text> 862 <xsl:value-of select="name(.)"/> 863 </xsl:attribute> 864 <xsl:text>
 </xsl:text> 865 <xsl:element name="xsl:apply-templates"> 866 <xsl:attribute name="mode"> 867 <xsl:value-of select="$mode"/> 868 </xsl:attribute> 869 <xsl:attribute name="select"> 870 <xsl:value-of select="$altinfo"/> 871 <xsl:text>/</xsl:text> 872 <xsl:value-of select="name(.)"/> 873 <xsl:if test="@predicate"> 874 <xsl:value-of select="@predicate"/> 875 </xsl:if> 876 </xsl:attribute> 877 </xsl:element> 878 <xsl:text>
 </xsl:text> 879 </xsl:element> 880 </xsl:if> 881 882 <xsl:text>
 </xsl:text> 883 <xsl:element name="xsl:when"> 884 <xsl:attribute name="test"> 885 <xsl:value-of select="name(.)"/> 886 </xsl:attribute> 887 <xsl:text>
 </xsl:text> 888 <xsl:element name="xsl:apply-templates"> 889 <xsl:attribute name="mode"> 890 <xsl:value-of select="$mode"/> 891 </xsl:attribute> 892 <xsl:attribute name="select"> 893 <xsl:value-of select="name(.)"/> 894 <xsl:if test="@predicate"> 895 <xsl:value-of select="@predicate"/> 896 </xsl:if> 897 </xsl:attribute> 898 </xsl:element> 899 <xsl:text>
 </xsl:text> 900 </xsl:element> 901 <xsl:text>
 </xsl:text> 902 </xsl:element> 903 <xsl:text>
</xsl:text> 904 </xsl:when> 905 <xsl:otherwise> 906 907 <!-- first take care of the $docinfo version --> 908 <xsl:element name="xsl:apply-templates"> 909 <xsl:attribute name="mode"> 910 <xsl:value-of select="$mode"/> 911 </xsl:attribute> 912 <xsl:attribute name="select"> 913 <xsl:value-of select="$docinfo"/> 914 <xsl:text>/</xsl:text> 915 <xsl:value-of select="name(.)"/> 916 <xsl:if test="@predicate"> 917 <xsl:value-of select="@predicate"/> 918 </xsl:if> 919 </xsl:attribute> 920 </xsl:element> 921 922 <!-- then take care of the $altinfo version --> 923 <xsl:if test="$altinfo != ''"> 924 <xsl:text>
 </xsl:text> 925 <xsl:element name="xsl:apply-templates"> 926 <xsl:attribute name="mode"> 927 <xsl:value-of select="$mode"/> 928 </xsl:attribute> 929 <xsl:attribute name="select"> 930 <xsl:value-of select="$altinfo"/> 931 <xsl:text>/</xsl:text> 932 <xsl:value-of select="name(.)"/> 933 <xsl:if test="@predicate"> 934 <xsl:value-of select="@predicate"/> 935 </xsl:if> 936 </xsl:attribute> 937 </xsl:element> 938 </xsl:if> 939 </xsl:otherwise> 940 </xsl:choose> 941 </xsl:otherwise> 942 </xsl:choose> 943</xsl:template> 944 945<!-- ==================================================================== --> 946 947<doc:template match="*" mode="titlepage.specialrules" xmlns=""> 948<refpurpose>Create templates for special rules</refpurpose> 949 950<refdescription> 951<para>This template is called to process all of the descendants of the 952<literal>t:titlepage-content</literal> element that require special 953processing. At present, that's just <literal>t:or</literal> elements. 954</para> 955</refdescription> 956</doc:template> 957 958<xsl:template match="*" mode="titlepage.specialrules"> 959 <xsl:variable name="side"> 960 <xsl:choose> 961 <xsl:when test="ancestor::t:titlepage-content/@side"> 962 <xsl:value-of select="ancestor::t:titlepage-content/@side"/> 963 </xsl:when> 964 <xsl:otherwise>recto</xsl:otherwise> 965 </xsl:choose> 966 </xsl:variable> 967 968 <xsl:variable name="mode"> 969 <xsl:value-of select="ancestor::t:titlepage/@element"/> 970 <xsl:text>.titlepage.</xsl:text> 971 <xsl:value-of select="$side"/> 972 <xsl:text>.auto.mode</xsl:text> 973 </xsl:variable> 974 975 <xsl:choose> 976 <xsl:when test="name(.)='t:or'"> 977 <xsl:apply-templates select="*" mode="titlepage.specialrules"/> 978 </xsl:when> 979 <xsl:otherwise> 980 <xsl:if test="*"><!-- does this element have children? --> 981 <xsl:text>

</xsl:text> 982 <xsl:element name="xsl:template"> 983 <xsl:attribute name="match"> 984 <xsl:value-of select="name(.)"/> 985 </xsl:attribute> 986 <xsl:attribute name="mode"> 987 <xsl:value-of select="$mode"/> 988 </xsl:attribute> 989 <xsl:apply-templates select="*" mode="titlepage.subrules"/> 990 <xsl:text>
</xsl:text> 991 </xsl:element> 992 </xsl:if> 993 </xsl:otherwise> 994 </xsl:choose> 995</xsl:template> 996 997<!-- ==================================================================== --> 998 999<doc:template match="*" mode="titlepage.subrules" xmlns=""> 1000<refpurpose>Create template for individual special rules</refpurpose> 1001 1002<refdescription> 1003<para>This template is called to process the children of special 1004template elements. 1005</para> 1006</refdescription> 1007</doc:template> 1008 1009<xsl:template match="*" mode="titlepage.subrules"> 1010 <xsl:variable name="side"> 1011 <xsl:choose> 1012 <xsl:when test="ancestor::t:titlepage-content/@side"> 1013 <xsl:value-of select="ancestor::t:titlepage-content/@side"/> 1014 </xsl:when> 1015 <xsl:otherwise>recto</xsl:otherwise> 1016 </xsl:choose> 1017 </xsl:variable> 1018 1019 <xsl:variable name="mode"> 1020 <xsl:value-of select="ancestor::t:titlepage/@element"/> 1021 <xsl:text>.titlepage.</xsl:text> 1022 <xsl:value-of select="$side"/> 1023 <xsl:text>.auto.mode</xsl:text> 1024 </xsl:variable> 1025 1026 <xsl:element name="xsl:apply-templates"> 1027 <xsl:attribute name="select"> 1028 <xsl:value-of select="name(.)"/> 1029 </xsl:attribute> 1030 <xsl:attribute name="mode"> 1031 <xsl:value-of select="$mode"/> 1032 </xsl:attribute> 1033 </xsl:element> 1034</xsl:template> 1035 1036<!-- ==================================================================== --> 1037 1038<doc:template match="t:or" xmlns=""> 1039<refpurpose>Process the t:or special rule</refpurpose> 1040 1041<refdescription> 1042<para>This template processes t:or.</para> 1043</refdescription> 1044</doc:template> 1045 1046<xsl:template match="t:or"> 1047 <xsl:variable name="side"> 1048 <xsl:choose> 1049 <xsl:when test="ancestor::t:titlepage-content/@side"> 1050 <xsl:value-of select="ancestor::t:titlepage-content/@side"/> 1051 </xsl:when> 1052 <xsl:otherwise>recto</xsl:otherwise> 1053 </xsl:choose> 1054 </xsl:variable> 1055 1056 <xsl:variable name="mode"> 1057 <xsl:value-of select="ancestor::t:titlepage/@element"/> 1058 <xsl:text>.titlepage.</xsl:text> 1059 <xsl:value-of select="$side"/> 1060 <xsl:text>.auto.mode</xsl:text> 1061 </xsl:variable> 1062 1063 <xsl:text>
 </xsl:text> 1064 <xsl:element name="xsl:apply-templates"> 1065 <xsl:attribute name="select"> 1066 <xsl:call-template name="element-or-list"/> 1067 </xsl:attribute> 1068 <xsl:attribute name="mode"> 1069 <xsl:value-of select="$mode"/> 1070 </xsl:attribute> 1071 </xsl:element> 1072</xsl:template> 1073 1074<!-- ==================================================================== --> 1075 1076<doc:template match="t:or" mode="titlepage.subrules" xmlns=""> 1077<refpurpose>Process the t:or special rule in 1078titlepage.subrules mode</refpurpose> 1079 1080<refdescription> 1081<para>The titlepage.subrules mode doesn't apply to t:or, so just 1082reprocess this node in the normal mode.</para> 1083</refdescription> 1084</doc:template> 1085 1086<xsl:template match="t:or" mode="titlepage.subrules"> 1087 <xsl:apply-templates select="."/><!-- use normal mode --> 1088</xsl:template> 1089 1090<!-- ==================================================================== --> 1091 1092<doc:template name="element-or-list" xmlns=""> 1093<refpurpose>Construct the "or-list" used in the select attribute for 1094special rules.</refpurpose> 1095 1096<refdescription> 1097<para>Walk through each of the children of t:or, producing the 1098text of the select attribute.</para> 1099</refdescription> 1100</doc:template> 1101 1102<xsl:template name="element-or-list"> 1103 <xsl:param name="elements" select="*"/> 1104 <xsl:param name="element.count" select="count($elements)"/> 1105 <xsl:param name="count" select="1"/> 1106 <xsl:param name="orlist"></xsl:param> 1107 1108 <xsl:choose> 1109 <xsl:when test="$count>$element.count"> 1110 <xsl:value-of select="$orlist"/> 1111 </xsl:when> 1112 <xsl:otherwise> 1113 <xsl:call-template name="element-or-list"> 1114 <xsl:with-param name="elements" select="$elements"/> 1115 <xsl:with-param name="element.count" select="$element.count"/> 1116 <xsl:with-param name="count" select="$count+1"/> 1117 <xsl:with-param name="orlist"> 1118 <xsl:value-of select="$orlist"/> 1119 <xsl:if test="not($orlist='')">|</xsl:if> 1120 <xsl:value-of select="name($elements[position()=$count])"/> 1121 </xsl:with-param> 1122 </xsl:call-template> 1123 </xsl:otherwise> 1124 </xsl:choose> 1125</xsl:template> 1126 1127<!-- ==================================================================== --> 1128 1129</xsl:stylesheet> 1130