$Id: titlepage.xsl,v 1.3 2001/08/01 08:56:17 nwalsh Exp $
Walsh Norman
1999 2000 Norman Walsh

# Template Stylesheet Reference

### Introduction

This is technical reference documentation for the DocBook XSL Stylesheets; it documents (some of) the parameters, templates, and other elements of the stylesheets.

This is not intended to be user documentation. It is provided for developers writing customization layers for the stylesheets, and for anyone who's interested in how it works.

Although I am trying to be thorough, this documentation is known to be incomplete. Don't forget to read the source, too :-)

t:templates Construct a stylesheet for the templates provided

    <xsl:template match="t:templates"/>

The `t:templates` element is the root of a set of templates. This template creates an appropriate `xsl:stylesheet` for the templates.

If the `t:templates` element has a `base-stylesheet` attribute, an `xsl:import` statement is constructed for it.

xsl:* Copy xsl: elements straight through

    <xsl:template match="xsl:*"/>

This template simply copies the xsl: elements straight through into the result tree.

t:titlepage Create the templates necessary to construct a title page

    <xsl:template match="t:titlepage"/>

The `t:titlepage` element creates a set of templates for processing the titlepage for an element. The root of this template set is the template named `wrapper.titlepage`. That is the template that should be called to generate the title page.

The `t:titlepage` element has three attributes:

element

  The name of the source document element for which these templates apply. In other words, to make a title page for the article element, set the element attribute to `article`. This attribute is required.

wrapper

  The entire title page can be wrapped with an element. This attribute identifies that element.

class

  If the class attribute is set, a class attribute with this value will be added to the wrapper element that surrounds the entire title page.

Any other attributes are copied through literally to the wrapper element.

The content of a `t:titlepage` is one or more `t:titlepage-content`, `t:titlepage-separator`, and `t:titlepage-before` elements.

Each of these elements may be provided for the recto and verso sides of the title page.

@* (in copy.literal.atts mode) Copy t:titlepage attributes

    <xsl:template match="@*" mode="copy.literal.atts"/>

This template copies all of the other attributes from a `t:titlepage` element onto the specified wrapper.

t:titlepage-content Create templates for the content of one side of a title page

    <xsl:template match="t:titlepage-content"/>

The title page content, that is, the elements from the source document that are rendered on the title page, can be controlled independently for the recto and verso sides of the title page.

The `t:titlepage-content` element has two attributes:

side

  Identifies the side of the page to which this title page content applies. The side attribute is required and must be set to either `recto` or `verso`. In addition, you must specify exactly one `t:titlepage-content` for each side within each `t:titlepage`.

order

  Indicates how the order of the elements presented on the title page is determined. If the order is `document`, the elements are presented in document order. Otherwise (if the order is `stylesheet`), the elements are presented in the order that they appear in the template (and consequently in the stylesheet).

The content of a `t:titlepage-content` element is a list of element names. These names should be unqualified. They identify the elements in the source document that should appear on the title page.

Each element may have a single attribute: predicate. The value of this attribute is used as a predicate for the expression that matches the element on which it occurs.

In other words, to put only the first three authors on the recto-side of a title page, you could specify:

      <t:titlepage-contents side="recto">
        <!-- other titlepage elements -->
        <author predicate="[count(previous-sibling::author)<2]"/>
        <!-- other titlepage elements -->
      </t:titlepage-contents>

Usually, the elements so named are empty. But it is possible to make one level of selection within them. Suppose that you want to process `authorgroup` elements on the title page, but you want to select only proper authors, editors, or corporate authors, not collaborators or other credited authors.

In that case, you can put a `t:or` group inside the `authorgroup` element:

      <t:titlepage-contents side="recto">
        <!-- other titlepage elements -->
        <authorgroup>
          <t:or>
            <author/>
            <editor/>
            <corpauthor/>
          </t:or>
        </authorgroup>
        <!-- other titlepage elements -->
      </t:titlepage-contents>

This will have the effect of automatically generating a template for processing `authorgroup`s in the title page mode, selecting only the specified children. If you need more complex processing, you'll have to construct the templates by hand.

t:titlepage-separator Create templates for the separator

    <xsl:template match="t:titlepage-separator"/>

The title page is separated from the content which follows it by the markup specified in the `t:titlepage-separator` element.

t:titlepage-before Create templates for what precedes a title page

    <xsl:template match="t:titlepage-before"/>

Each side of the title page is preceded by the markup specified in the `t:titlepage-before` element for that side.

* (in copy mode) Copy elements

    <xsl:template match="*" mode="copy"/>

This template simply copies the elements that it applies to straight through into the result tree.

@* (in copy mode) Copy attributes

    <xsl:template match="@*" mode="copy"/>

This template simply copies the attributes that it applies to straight through into the result tree.

* (in document.order mode) Create rules to process titlepage elements in document order

    <xsl:template match="*" mode="document.order"/>

This template is called to process all of the children of the `t:titlepage-content` element. It creates the hairy select expression necessary to process each of those elements in the title page.

Note that this template automatically handles the case where some DocBook elements, like title and subtitle, can occur both inside the *info elements where metadata is usually stored and outside.

It also automatically calculates the name for the *info container and handles elements that have historically had containers with different names.

* (in document.order mode) Create rules to process titlepage elements in stylesheet order

    <xsl:template match="*" mode="document.order"/>

This template is called to process all of the children of the `t:titlepage-content` element. It creates the set of `xsl:apply-templates` elements necessary process each of those elements in the title page.

Note that this template automatically handles the case where some DocBook elements, like title and subtitle, can occur both inside the *info elements where metadata is usually stored and outside.

It also automatically calculates the name for the *info container and handles elements that have historically had containers with different names.

* (in titlepage.specialrules mode) Create templates for special rules

    <xsl:template match="*" mode="titlepage.specialrules"/>

This template is called to process all of the descendants of the `t:titlepage-content` element that require special processing. At present, that's just `t:or` elements.

* (in titlepage.subrules mode) Create template for individual special rules

    <xsl:template match="*" mode="titlepage.subrules"/>

This template is called to process the children of special template elements.

t:or Process the t:or special rule

    <xsl:template match="t:or"/><xsl:template match="t:or" mode="titlepage.subrules"/>

This template processes t:or.

t:or (in titlepage.subrules mode) Process the t:or special rule in titlepage.subrules mode

    <xsl:template match="t:or" mode="titlepage.subrules"/>

The titlepage.subrules mode doesn't apply to t:or, so just reprocess this node in the normal mode.

element-or-list Construct the "or-list" used in the select attribute for special rules.

    <xsl:template name="element-or-list">
    <xsl:param name="elements" select="*"/>
    <xsl:param name="element.count" select="count($elements)"/>
    <xsl:param name="count" select="1"/>
    <xsl:param name="orlist"/>
      ...
    </xsl:template>

Walk through each of the children of t:or, producing the text of the select attribute.