<doc:reference xml:id="base">
<info>
<title>Common » Base Template Reference</title>
<releaseinfo role="meta">
$Id$
</releaseinfo>
</info>
<partintro xml:id="partintro">
<title>Introduction</title>
<para>This is technical reference documentation for the “base”
set of common templates in the DocBook XSL Stylesheets.</para>
<para>This is not intended to be user documentation. It is
provided for developers writing customization layers for the
stylesheets.</para>
</partintro>
</doc:reference>
<doc:template name="is.component">
<refpurpose>Tests if a given node is a component-level element</refpurpose>
<refdescription id="is.component-desc">
<para>This template returns '1' if the specified node is a component
(Chapter, Appendix, etc.), and '0' otherwise.</para>
</refdescription>
<refparameter id="is.component-params">
<variablelist>
<varlistentry><term>node</term>
<listitem>
<para>The node which is to be tested.</para>
</listitem>
</varlistentry>
</variablelist>
</refparameter>
<refreturn id="is.component-returns">
<para>This template returns '1' if the specified node is a component
(Chapter, Appendix, etc.), and '0' otherwise.</para>
</refreturn>
</doc:template>
<xsl:template name="is.component"><xsl:param name="node" select="."/><xsl:choose><xsl:when test="local-name($node) = 'appendix' or local-name($node) = 'article' or local-name($node) = 'chapter' or local-name($node) = 'preface' or local-name($node) = 'bibliography' or local-name($node) = 'glossary' or local-name($node) = 'index'">1</xsl:when><xsl:otherwise>0</xsl:otherwise></xsl:choose></xsl:template>
Template
is.section
Documentation
<doc:template name="is.section">
<refpurpose>Tests if a given node is a section-level element</refpurpose>
<refdescription id="is.section-desc">
<para>This template returns '1' if the specified node is a section
(Section, Sect1, Sect2, etc.), and '0' otherwise.</para>
</refdescription>
<refparameter id="is.section-params">
<variablelist>
<varlistentry><term>node</term>
<listitem>
<para>The node which is to be tested.</para>
</listitem>
</varlistentry>
</variablelist>
</refparameter>
<refreturn id="is.section-returns">
<para>This template returns '1' if the specified node is a section
(Section, Sect1, Sect2, etc.), and '0' otherwise.</para>
</refreturn>
</doc:template>
<xsl:template name="is.section"><xsl:param name="node" select="."/><xsl:choose><xsl:when test="local-name($node) = 'section' or local-name($node) = 'sect1' or local-name($node) = 'sect2' or local-name($node) = 'sect3' or local-name($node) = 'sect4' or local-name($node) = 'sect5' or local-name($node) = 'refsect1' or local-name($node) = 'refsect2' or local-name($node) = 'refsect3' or local-name($node) = 'simplesect'">1</xsl:when><xsl:otherwise>0</xsl:otherwise></xsl:choose></xsl:template>
Template
section.level
Documentation
<doc:template name="section.level">
<refpurpose>Returns the hierarchical level of a section</refpurpose>
<refdescription id="section.level-desc">
<para>This template calculates the hierarchical level of a section.
The element <tag>sect1</tag> is at level 1, <tag>sect2</tag> is
at level 2, etc.</para>
<para>Recursive sections are calculated down to the fifth level.</para>
</refdescription>
<refparameter id="section.level-params">
<variablelist>
<varlistentry><term>node</term>
<listitem>
<para>The section node for which the level should be calculated.
Defaults to the context node.</para>
</listitem>
</varlistentry>
</variablelist>
</refparameter>
<refreturn id="section.level-returns">
<para>The section level, <quote>1</quote>, <quote>2</quote>, etc.
</para>
</refreturn>
</doc:template>
<xsl:template name="section.level"><xsl:param name="node" select="."/><xsl:choose><xsl:when test="local-name($node)='sect1'">1</xsl:when><xsl:when test="local-name($node)='sect2'">2</xsl:when><xsl:when test="local-name($node)='sect3'">3</xsl:when><xsl:when test="local-name($node)='sect4'">4</xsl:when><xsl:when test="local-name($node)='sect5'">5</xsl:when><xsl:when test="local-name($node)='section'"><xsl:choose><xsl:when test="$node/../../../../../../d:section">6</xsl:when><xsl:when test="$node/../../../../../d:section">5</xsl:when><xsl:when test="$node/../../../../d:section">4</xsl:when><xsl:when test="$node/../../../d:section">3</xsl:when><xsl:when test="$node/../../d:section">2</xsl:when><xsl:otherwise>1</xsl:otherwise></xsl:choose></xsl:when><xsl:when test="local-name($node)='refsect1' or local-name($node)='refsect2' or local-name($node)='refsect3' or local-name($node)='refsection' or local-name($node)='refsynopsisdiv'"><xsl:call-template name="refentry.section.level"><xsl:with-param name="node" select="$node"/></xsl:call-template></xsl:when><xsl:when test="local-name($node)='simplesect'"><xsl:choose><xsl:when test="$node/../../d:sect1">2</xsl:when><xsl:when test="$node/../../d:sect2">3</xsl:when><xsl:when test="$node/../../d:sect3">4</xsl:when><xsl:when test="$node/../../d:sect4">5</xsl:when><xsl:when test="$node/../../d:sect5">5</xsl:when><xsl:when test="$node/../../d:section"><xsl:choose><xsl:when test="$node/../../../../../d:section">5</xsl:when><xsl:when test="$node/../../../../d:section">4</xsl:when><xsl:when test="$node/../../../d:section">3</xsl:when><xsl:otherwise>2</xsl:otherwise></xsl:choose></xsl:when><xsl:otherwise>1</xsl:otherwise></xsl:choose></xsl:when><xsl:otherwise>1</xsl:otherwise></xsl:choose></xsl:template>
Template
qanda.section.level
Documentation
<doc:template name="qanda.section.level">
<refpurpose>Returns the hierarchical level of a QandASet</refpurpose>
<refdescription id="qanda.section.level-desc">
<para>This template calculates the hierarchical level of a QandASet.
</para>
</refdescription>
<refreturn id="qanda.section.level-returns">
<para>The level, <quote>1</quote>, <quote>2</quote>, etc.
</para>
</refreturn>
</doc:template>
<xsl:template name="person.name"><!-- Formats a personal name. Handles corpauthor as a special case. --><xsl:param name="node" select="."/><xsl:variable name="style"><xsl:choose><xsl:when test="$node/@role"><xsl:value-of select="$node/@role"/></xsl:when><xsl:otherwise><xsl:call-template name="gentext.template"><xsl:with-param name="context" select="'styles'"/><xsl:with-param name="name" select="'person-name'"/></xsl:call-template></xsl:otherwise></xsl:choose></xsl:variable><xsl:choose><!-- the personname element is a specialcase --><xsl:when test="$node/d:personname"><xsl:call-template name="person.name"><xsl:with-param name="node" select="$node/d:personname"/></xsl:call-template></xsl:when><!-- handle corpauthor as a special case...--><!-- * MikeSmith 2007-06: I'm wondering if the person.name template --><!-- * actually ever gets called to handle corpauthor.. maybe --><!-- * we don't actually need to check for corpauthor here. --><xsl:when test="local-name($node)='corpauthor'"><xsl:apply-templates select="$node"/></xsl:when><xsl:otherwise><xsl:choose><!-- Handle case when personname contains only general markup (DocBook 5.0) --><xsl:when test="$node/self::d:personname and not($node/d:firstname or $node/d:honorific or $node/d:lineage or $node/d:othername or $node/d:surname)"><xsl:apply-templates select="$node/node()"/></xsl:when><xsl:when test="$style = 'family-given'"><xsl:call-template name="person.name.family-given"><xsl:with-param name="node" select="$node"/></xsl:call-template></xsl:when><xsl:when test="$style = 'last-first'"><xsl:call-template name="person.name.last-first"><xsl:with-param name="node" select="$node"/></xsl:call-template></xsl:when><xsl:otherwise><xsl:call-template name="person.name.first-last"><xsl:with-param name="node" select="$node"/></xsl:call-template></xsl:otherwise></xsl:choose></xsl:otherwise></xsl:choose></xsl:template>
<xsl:template name="person.name.family-given"><xsl:param name="node" select="."/><!-- The family-given style applies a convention for identifying given --><!-- and family names in locales where it may be ambiguous --><xsl:apply-templates select="$node//d:surname[1]"/><xsl:if test="$node//d:surname and $node//d:firstname"><xsl:text></xsl:text></xsl:if><xsl:apply-templates select="$node//d:firstname[1]"/><xsl:text> [FAMILY Given]</xsl:text></xsl:template>
<xsl:template name="person.name.list"><!-- Return a formatted string representation of the contents of
the current element. The current element must contain one or
more AUTHORs, CORPAUTHORs, OTHERCREDITs, and/or EDITORs.
John Doe
or
John Doe and Jane Doe
or
John Doe, Jane Doe, and A. Nonymous
--><xsl:param name="person.list" select="d:author|d:corpauthor|d:othercredit|d:editor"/><xsl:param name="person.count" select="count($person.list)"/><xsl:param name="count" select="1"/><xsl:choose><xsl:when test="$count > $person.count"/><xsl:otherwise><xsl:call-template name="person.name"><xsl:with-param name="node" select="$person.list[position()=$count]"/></xsl:call-template><xsl:choose><xsl:when test="$person.count = 2 and $count = 1"><xsl:call-template name="gentext.template"><xsl:with-param name="context" select="'authorgroup'"/><xsl:with-param name="name" select="'sep2'"/></xsl:call-template></xsl:when><xsl:when test="$person.count > 2 and $count+1 = $person.count"><xsl:call-template name="gentext.template"><xsl:with-param name="context" select="'authorgroup'"/><xsl:with-param name="name" select="'seplast'"/></xsl:call-template></xsl:when><xsl:when test="$count < $person.count"><xsl:call-template name="gentext.template"><xsl:with-param name="context" select="'authorgroup'"/><xsl:with-param name="name" select="'sep'"/></xsl:call-template></xsl:when></xsl:choose><xsl:call-template name="person.name.list"><xsl:with-param name="person.list" select="$person.list"/><xsl:with-param name="person.count" select="$person.count"/><xsl:with-param name="count" select="$count+1"/></xsl:call-template></xsl:otherwise></xsl:choose></xsl:template>
<xsl:template name="filename-extension"><xsl:param name="filename"/><xsl:param name="recurse" select="false()"/><!-- Make sure we only look at the base name... --><xsl:variable name="basefn"><xsl:choose><xsl:when test="$recurse"><xsl:value-of select="$filename"/></xsl:when><xsl:otherwise><xsl:call-template name="filename-basename"><xsl:with-param name="filename" select="$filename"/></xsl:call-template></xsl:otherwise></xsl:choose></xsl:variable><xsl:choose><xsl:when test="substring-after($basefn, '.') != ''"><xsl:call-template name="filename-extension"><xsl:with-param name="filename" select="substring-after($basefn, '.')"/><xsl:with-param name="recurse" select="true()"/></xsl:call-template></xsl:when><xsl:when test="$recurse"><xsl:value-of select="$basefn"/></xsl:when><xsl:otherwise/></xsl:choose></xsl:template>
Template
select.mediaobject
Documentation
<doc:template name="select.mediaobject">
<refpurpose>Selects and processes an appropriate media object from a list</refpurpose>
<refdescription id="select.mediaobject-desc">
<para>This template takes a list of media objects (usually the
children of a mediaobject or inlinemediaobject) and processes
the "right" object.</para>
<para>This template relies on a template named
"select.mediaobject.index" to determine which object
in the list is appropriate.</para>
<para>If no acceptable object is located, nothing happens.</para>
</refdescription>
<refparameter id="select.mediaobject-params">
<variablelist>
<varlistentry><term>olist</term>
<listitem>
<para>The node list of potential objects to examine.</para>
</listitem>
</varlistentry>
</variablelist>
</refparameter>
<refreturn id="select.mediaobject-returns">
<para>Calls <xsl:apply-templates> on the selected object.</para>
</refreturn>
</doc:template>
<doc:template name="select.mediaobject.index">
<refpurpose>Selects the position of the appropriate media object from a list</refpurpose>
<refdescription id="select.mediaobject.index-desc">
<para>This template takes a list of media objects (usually the
children of a mediaobject or inlinemediaobject) and determines
the "right" object. It returns the position of that object
to be used by the calling template.</para>
<para>If the parameter <parameter>use.role.for.mediaobject</parameter>
is nonzero, then it first checks for an object with
a role attribute of the appropriate value. It takes the first
of those. Otherwise, it takes the first acceptable object
through a recursive pass through the list.</para>
<para>This template relies on a template named "is.acceptable.mediaobject"
to determine if a given object is an acceptable graphic. The semantics
of media objects is that the first acceptable graphic should be used.
</para>
<para>If no acceptable object is located, no index is returned.</para>
</refdescription>
<refparameter id="select.mediaobject.index-params">
<variablelist>
<varlistentry><term>olist</term>
<listitem>
<para>The node list of potential objects to examine.</para>
</listitem>
</varlistentry>
<varlistentry><term>count</term>
<listitem>
<para>The position in the list currently being considered by the
recursive process.</para>
</listitem>
</varlistentry>
</variablelist>
</refparameter>
<refreturn id="select.mediaobject.index-returns">
<para>Returns the position in the original list of the selected object.</para>
</refreturn>
</doc:template>
<xsl:template name="select.mediaobject.index"><xsl:param name="olist" select="d:imageobject|d:imageobjectco |d:videoobject|d:audioobject|d:textobject"/><xsl:param name="count">1</xsl:param><xsl:choose><!-- Test for objects preferred by role --><xsl:when test="$use.role.for.mediaobject != 0 and $preferred.mediaobject.role != '' and $olist[@role = $preferred.mediaobject.role]"><!-- Get the first hit's position index --><xsl:for-each select="$olist"><xsl:if test="@role = $preferred.mediaobject.role and not(preceding-sibling::*[@role = $preferred.mediaobject.role])"><xsl:value-of select="position()"/></xsl:if></xsl:for-each></xsl:when><xsl:when test="$use.role.for.mediaobject != 0 and $olist[@role = $stylesheet.result.type]"><!-- Get the first hit's position index --><xsl:for-each select="$olist"><xsl:if test="@role = $stylesheet.result.type and not(preceding-sibling::*[@role = $stylesheet.result.type])"><xsl:value-of select="position()"/></xsl:if></xsl:for-each></xsl:when><!-- Accept 'html' for $stylesheet.result.type = 'xhtml' --><xsl:when test="$use.role.for.mediaobject != 0 and $stylesheet.result.type = 'xhtml' and $olist[@role = 'html']"><!-- Get the first hit's position index --><xsl:for-each select="$olist"><xsl:if test="@role = 'html' and not(preceding-sibling::*[@role = 'html'])"><xsl:value-of select="position()"/></xsl:if></xsl:for-each></xsl:when><!-- If no selection by role, and there is only one object, use it --><xsl:when test="count($olist) = 1 and $count = 1"><xsl:value-of select="$count"/></xsl:when><xsl:otherwise><!-- Otherwise select first acceptable object --><xsl:if test="$count <= count($olist)"><xsl:variable name="object" select="$olist[position()=$count]"/><xsl:variable name="useobject"><xsl:choose><!-- The phrase is used only when contains TeX Math and output is FO --><xsl:when test="local-name($object)='textobject' and $object/d:phrase and $object/@role='tex' and $stylesheet.result.type = 'fo' and $tex.math.in.alt != ''"><xsl:text>1</xsl:text></xsl:when><!-- The phrase is never used --><xsl:when test="local-name($object)='textobject' and $object/d:phrase"><xsl:text>0</xsl:text></xsl:when><xsl:when test="local-name($object)='textobject' and $object/ancestor::d:equation "><!-- The first textobject is not a reasonable fallback
for equation image --><xsl:text>0</xsl:text></xsl:when><!-- The first textobject is a reasonable fallback --><xsl:when test="local-name($object)='textobject' and $object[not(@role) or @role!='tex']"><xsl:text>1</xsl:text></xsl:when><!-- don't use graphic when output is FO, TeX Math is used
and there is math in alt element --><xsl:when test="$object/ancestor::d:equation and $object/ancestor::d:equation/d:alt[@role='tex'] and $stylesheet.result.type = 'fo' and $tex.math.in.alt != ''"><xsl:text>0</xsl:text></xsl:when><!-- If there's only one object, use it --><xsl:when test="$count = 1 and count($olist) = 1"><xsl:text>1</xsl:text></xsl:when><!-- Otherwise, see if this one is a useable graphic --><xsl:otherwise><xsl:choose><!-- peek inside imageobjectco to simplify the test --><xsl:when test="local-name($object) = 'imageobjectco'"><xsl:call-template name="is.acceptable.mediaobject"><xsl:with-param name="object" select="$object/d:imageobject"/></xsl:call-template></xsl:when><xsl:otherwise><xsl:call-template name="is.acceptable.mediaobject"><xsl:with-param name="object" select="$object"/></xsl:call-template></xsl:otherwise></xsl:choose></xsl:otherwise></xsl:choose></xsl:variable><xsl:choose><xsl:when test="$useobject='1'"><xsl:value-of select="$count"/></xsl:when><xsl:otherwise><xsl:call-template name="select.mediaobject.index"><xsl:with-param name="olist" select="$olist"/><xsl:with-param name="count" select="$count + 1"/></xsl:call-template></xsl:otherwise></xsl:choose></xsl:if></xsl:otherwise></xsl:choose></xsl:template>
Template
is.acceptable.mediaobject
Documentation
<doc:template name="is.acceptable.mediaobject">
<refpurpose>Returns '1' if the specified media object is recognized</refpurpose>
<refdescription id="is.acceptable.mediaobject-desc">
<para>This template examines a media object and returns '1' if the
object is recognized as a graphic.</para>
</refdescription>
<refparameter id="is.acceptable.mediaobject-params">
<variablelist>
<varlistentry><term>object</term>
<listitem>
<para>The media object to consider.</para>
</listitem>
</varlistentry>
</variablelist>
</refparameter>
<refreturn id="is.acceptable.mediaobject-returns">
<para>0 or 1</para>
</refreturn>
</doc:template>
<doc:template name="check.id.unique">
<refpurpose>Warn users about references to non-unique IDs</refpurpose>
<refdescription id="check.id.unique-desc">
<para>If passed an ID in <varname>linkend</varname>,
<function>check.id.unique</function> prints
a warning message to the user if either the ID does not exist or
the ID is not unique.</para>
</refdescription>
</doc:template>
<xsl:template name="check.id.unique"><xsl:param name="linkend"/><xsl:if test="$linkend != ''"><xsl:variable name="targets" select="key('id',$linkend)"/><xsl:variable name="target" select="$targets[1]"/><xsl:if test="count($targets)=0"><xsl:message><xsl:text>Error: no ID for constraint linkend: </xsl:text><xsl:value-of select="$linkend"/><xsl:text>.</xsl:text></xsl:message><!--
<xsl:message>
<xsl:text>If the ID exists in your document, did your </xsl:text>
<xsl:text>XSLT Processor load the DTD?</xsl:text>
</xsl:message>
--></xsl:if><xsl:if test="count($targets)>1"><xsl:message><xsl:text>Warning: multiple "IDs" for constraint linkend: </xsl:text><xsl:value-of select="$linkend"/><xsl:text>.</xsl:text></xsl:message></xsl:if></xsl:if></xsl:template>
Template
check.idref.targets
Documentation
<doc:template name="check.idref.targets">
<refpurpose>Warn users about incorrectly typed references</refpurpose>
<refdescription id="check.idref.targets-desc">
<para>If passed an ID in <varname>linkend</varname>,
<function>check.idref.targets</function> makes sure that the element
pointed to by the link is one of the elements listed in
<varname>element-list</varname> and warns the user otherwise.</para>
</refdescription>
</doc:template>
<xsl:template name="next.numeration"><xsl:param name="numeration" select="'default'"/><xsl:choose><!-- Change this list if you want to change the order of numerations --><xsl:when test="$numeration = 'arabic'">loweralpha</xsl:when><xsl:when test="$numeration = 'loweralpha'">lowerroman</xsl:when><xsl:when test="$numeration = 'lowerroman'">upperalpha</xsl:when><xsl:when test="$numeration = 'upperalpha'">upperroman</xsl:when><xsl:when test="$numeration = 'upperroman'">arabic</xsl:when><xsl:otherwise>arabic</xsl:otherwise></xsl:choose></xsl:template>
<xsl:template name="next.itemsymbol"><xsl:param name="itemsymbol" select="'default'"/><xsl:choose><!-- Change this list if you want to change the order of symbols --><xsl:when test="$itemsymbol = 'disc'">circle</xsl:when><xsl:when test="$itemsymbol = 'circle'">square</xsl:when><xsl:otherwise>disc</xsl:otherwise></xsl:choose></xsl:template>
<doc:template name="copyright.years">
<refpurpose>Print a set of years with collapsed ranges</refpurpose>
<refdescription id="copyright.years-desc">
<para>This template prints a list of year elements with consecutive
years printed as a range. In other words:</para>
<screen><year>1992</year>
<year>1993</year>
<year>1994</year></screen>
<para>is printed <quote>1992-1994</quote>, whereas:</para>
<screen><year>1992</year>
<year>1994</year></screen>
<para>is printed <quote>1992, 1994</quote>.</para>
<para>This template assumes that all the year elements contain only
decimal year numbers, that the elements are sorted in increasing
numerical order, that there are no duplicates, and that all the years
are expressed in full <quote>century+year</quote>
(<quote>1999</quote> not <quote>99</quote>) notation.</para>
</refdescription>
<refparameter id="copyright.years-params">
<variablelist>
<varlistentry><term>years</term>
<listitem>
<para>The initial set of year elements.</para>
</listitem>
</varlistentry>
<varlistentry><term>print.ranges</term>
<listitem>
<para>If non-zero, multi-year ranges are collapsed. If zero, all years
are printed discretely.</para>
</listitem>
</varlistentry>
<varlistentry><term>single.year.ranges</term>
<listitem>
<para>If non-zero, two consecutive years will be printed as a range,
otherwise, they will be printed discretely. In other words, a single
year range is <quote>1991-1992</quote> but discretely it's
<quote>1991, 1992</quote>.</para>
</listitem>
</varlistentry>
</variablelist>
</refparameter>
<refreturn id="copyright.years-returns">
<para>This template returns the formatted list of years.</para>
</refreturn>
</doc:template>
<xsl:template name="copyright.years"><xsl:param name="years"/><xsl:param name="print.ranges" select="1"/><xsl:param name="single.year.ranges" select="0"/><xsl:param name="firstyear" select="0"/><xsl:param name="nextyear" select="0"/><!--
<xsl:message terminate="no">
<xsl:text>CY: </xsl:text>
<xsl:value-of select="count($years)"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="$firstyear"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="$nextyear"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="$print.ranges"/>
<xsl:text>, </xsl:text>
<xsl:value-of select="$single.year.ranges"/>
<xsl:text> (</xsl:text>
<xsl:value-of select="$years[1]"/>
<xsl:text>)</xsl:text>
</xsl:message>
--><xsl:choose><xsl:when test="$print.ranges = 0 and count($years) > 0"><xsl:choose><xsl:when test="count($years) = 1"><xsl:apply-templates select="$years[1]" mode="titlepage.mode"/></xsl:when><xsl:otherwise><xsl:apply-templates select="$years[1]" mode="titlepage.mode"/><xsl:text>, </xsl:text><xsl:call-template name="copyright.years"><xsl:with-param name="years" select="$years[position() > 1]"/><xsl:with-param name="print.ranges" select="$print.ranges"/><xsl:with-param name="single.year.ranges" select="$single.year.ranges"/></xsl:call-template></xsl:otherwise></xsl:choose></xsl:when><xsl:when test="count($years) = 0"><xsl:variable name="lastyear" select="$nextyear - 1"/><xsl:choose><xsl:when test="$firstyear = 0"><!-- there weren't any years at all --></xsl:when><!-- Just output a year with range in its text --><xsl:when test="contains($firstyear, '-') or contains($firstyear, ',')"><xsl:value-of select="$firstyear"/></xsl:when><xsl:when test="$firstyear = $lastyear"><xsl:value-of select="$firstyear"/></xsl:when><xsl:when test="$single.year.ranges = 0 and $lastyear = $firstyear + 1"><xsl:value-of select="$firstyear"/><xsl:text>, </xsl:text><xsl:value-of select="$lastyear"/></xsl:when><xsl:otherwise><xsl:value-of select="$firstyear"/><xsl:text>-</xsl:text><xsl:value-of select="$lastyear"/></xsl:otherwise></xsl:choose></xsl:when><xsl:when test="contains($firstyear, '-') or contains($firstyear, ',')"><!-- Just output a year with range in its text --><xsl:value-of select="$firstyear"/><xsl:if test="count($years) != 0"><xsl:text>, </xsl:text></xsl:if><xsl:call-template name="copyright.years"><xsl:with-param name="years" select="$years[position() > 1]"/><xsl:with-param name="firstyear" select="$years[1]"/><xsl:with-param name="nextyear" select="$years[1] + 1"/><xsl:with-param name="print.ranges" select="$print.ranges"/><xsl:with-param name="single.year.ranges" select="$single.year.ranges"/></xsl:call-template></xsl:when><xsl:when test="$firstyear = 0"><xsl:call-template name="copyright.years"><xsl:with-param name="years" select="$years[position() > 1]"/><xsl:with-param name="firstyear" select="$years[1]"/><xsl:with-param name="nextyear" select="$years[1] + 1"/><xsl:with-param name="print.ranges" select="$print.ranges"/><xsl:with-param name="single.year.ranges" select="$single.year.ranges"/></xsl:call-template></xsl:when><xsl:when test="$nextyear = $years[1]"><xsl:call-template name="copyright.years"><xsl:with-param name="years" select="$years[position() > 1]"/><xsl:with-param name="firstyear" select="$firstyear"/><xsl:with-param name="nextyear" select="$nextyear + 1"/><xsl:with-param name="print.ranges" select="$print.ranges"/><xsl:with-param name="single.year.ranges" select="$single.year.ranges"/></xsl:call-template></xsl:when><xsl:otherwise><!-- we have years left, but they aren't in the current range --><xsl:choose><xsl:when test="$nextyear = $firstyear + 1"><xsl:value-of select="$firstyear"/><xsl:text>, </xsl:text></xsl:when><xsl:when test="$single.year.ranges = 0 and $nextyear = $firstyear + 2"><xsl:value-of select="$firstyear"/><xsl:text>, </xsl:text><xsl:value-of select="$nextyear - 1"/><xsl:text>, </xsl:text></xsl:when><xsl:otherwise><xsl:value-of select="$firstyear"/><xsl:text>-</xsl:text><xsl:value-of select="$nextyear - 1"/><xsl:text>, </xsl:text></xsl:otherwise></xsl:choose><xsl:call-template name="copyright.years"><xsl:with-param name="years" select="$years[position() > 1]"/><xsl:with-param name="firstyear" select="$years[1]"/><xsl:with-param name="nextyear" select="$years[1] + 1"/><xsl:with-param name="print.ranges" select="$print.ranges"/><xsl:with-param name="single.year.ranges" select="$single.year.ranges"/></xsl:call-template></xsl:otherwise></xsl:choose></xsl:template>
Template
find.path.params
Documentation
<doc:template name="find.path.params">
<refpurpose>Search in a table for the "best" match for the node</refpurpose>
<refdescription id="find.path.params-desc">
<para>This template searches in a table for the value that most-closely
(in the typical best-match sense of XSLT) matches the current (element)
node location.</para>
</refdescription>
</doc:template>
<xsl:template name="xml.base.dirs"><xsl:param name="base.elem" select="NONODE"/><!-- Recursively resolve xml:base attributes, up to a
full path with : in uri --><xsl:if test="$base.elem/ancestor::*[@xml:base != ''] and not(contains($base.elem/@xml:base, ':'))"><xsl:call-template name="xml.base.dirs"><xsl:with-param name="base.elem" select="$base.elem/ancestor::*[@xml:base != ''][1]"/></xsl:call-template></xsl:if><xsl:call-template name="getdir"><xsl:with-param name="filename" select="$base.elem/@xml:base"/></xsl:call-template></xsl:template>
<doc:template name="string.upper">
<refpurpose>Converts a string to all uppercase letters</refpurpose>
<refdescription id="string.upper-desc">
<para>Given a string, this template does a language-aware conversion
of that string to all uppercase letters, based on the values of the
<literal>lowercase.alpha</literal> and
<literal>uppercase.alpha</literal> gentext keys for the current
locale. It affects only those characters found in the values of
<literal>lowercase.alpha</literal> and
<literal>uppercase.alpha</literal>. All other characters are left
unchanged.</para>
</refdescription>
<refparameter id="string.upper-params">
<variablelist>
<varlistentry><term>string</term>
<listitem>
<para>The string to convert to uppercase.</para>
</listitem>
</varlistentry>
</variablelist>
</refparameter>
</doc:template>
<doc:template name="string.lower">
<refpurpose>Converts a string to all lowercase letters</refpurpose>
<refdescription id="string.lower-desc">
<para>Given a string, this template does a language-aware conversion
of that string to all lowercase letters, based on the values of the
<literal>uppercase.alpha</literal> and
<literal>lowercase.alpha</literal> gentext keys for the current
locale. It affects only those characters found in the values of
<literal>uppercase.alpha</literal> and
<literal>lowercase.alpha</literal>. All other characters are left
unchanged.</para>
</refdescription>
<refparameter id="string.lower-params">
<variablelist>
<varlistentry><term>string</term>
<listitem>
<para>The string to convert to lowercase.</para>
</listitem>
</varlistentry>
</variablelist>
</refparameter>
</doc:template>
<doc:template name="select.choice.separator">
<refpurpose>Returns localized choice separator</refpurpose>
<refdescription id="select.choice.separator-desc">
<para>This template enables auto-generation of an appropriate
localized "choice" separator (for example, "and" or "or") before
the final item in an inline list (though it could also be useful
for generating choice separators for non-inline lists).</para>
<para>It currently works by evaluating a processing instruction
(PI) of the form <?dbchoice choice="foo"?> :
<itemizedlist>
<listitem>
<simpara>if the value of the <tag>choice</tag>
pseudo-attribute is "and" or "or", returns a localized "and"
or "or"</simpara>
</listitem>
<listitem>
<simpara>otherwise returns the literal value of the
<tag>choice</tag> pseudo-attribute</simpara>
</listitem>
</itemizedlist>
The latter is provided only as a temporary workaround because the
locale files do not currently have translations for the word
<wordasword>or</wordasword>. So if you want to generate a a
logical "or" separator in French (for example), you currently need
to do this:
<literallayout><?dbchoice choice="ou"?></literallayout>
</para>
<warning>
<para>The <tag>dbchoice</tag> processing instruction is
an unfortunate hack; support for it may disappear in the future
(particularly if and when a more appropriate means for marking
up "choice" lists becomes available in DocBook).</para>
</warning>
</refdescription>
</doc:template>
<xsl:template name="select.choice.separator"><xsl:variable name="choice"><xsl:call-template name="pi.dbchoice_choice"/></xsl:variable><xsl:choose><!-- if value of $choice is "and" or "or", translate to equivalent in --><!-- current locale --><xsl:when test="$choice = 'and' or $choice = 'or'"><xsl:call-template name="gentext"><xsl:with-param name="key" select="$choice"/></xsl:call-template></xsl:when><!-- otherwise, just output value of $choice, whatever it is --><xsl:otherwise><xsl:value-of select="$choice"/></xsl:otherwise></xsl:choose></xsl:template>
Template
evaluate.info.profile
Documentation
<doc:template name="evaluate.info.profile">
<refpurpose>Evaluates an info profile</refpurpose>
<refdescription id="evaluate.info.profile-desc">
<para>This template evaluates an "info profile" matching the XPath
expression given by the <parameter>profile</parameter>
parameter. It relies on the XSLT <function>evaluate()</function>
extension function.</para>
<para>The value of the <parameter>profile</parameter> parameter
can include the literal string <literal>$info</literal>. If found
in the value of the <parameter>profile</parameter> parameter, the
literal string <literal>$info</literal> string is replaced with
the value of the <parameter>info</parameter> parameter, which
should be a set of <replaceable>*info</replaceable> nodes; the
expression is then evaluated using the XSLT
<function>evaluate()</function> extension function.</para>
</refdescription>
<refparameter id="evaluate.info.profile-params">
<variablelist>
<varlistentry>
<term>profile</term>
<listitem>
<para>A string representing an XPath expression </para>
</listitem>
</varlistentry>
<varlistentry>
<term>info</term>
<listitem>
<para>A set of *info nodes</para>
</listitem>
</varlistentry>
</variablelist>
</refparameter>
<refreturn id="evaluate.info.profile-returns">
<para>Returns a node (the result of evaluating the
<parameter>profile</parameter> parameter)</para>
</refreturn>
</doc:template>
Description
=====================================
Namespace
No namespace
Parameters
QName
Namespace
info
No namespace
profile
No namespace
Import precedence
0
Source
<xsl:template name="evaluate.info.profile"><xsl:param name="profile"/><xsl:param name="info"/><xsl:choose><!-- * xsltproc and Xalan both support dyn:evaluate() --><xsl:when test="function-available('dyn:evaluate')"><xsl:apply-templates select="dyn:evaluate($profile)" mode="get.refentry.metadata"/></xsl:when><!-- * Saxon has its own evaluate() & doesn't support dyn:evaluate() --><xsl:when test="function-available('saxon:evaluate')"><xsl:apply-templates select="saxon:evaluate($profile)" mode="get.refentry.metadata"/></xsl:when><xsl:otherwise><xsl:message terminate="yes">Error: The "info profiling" mechanism currently requires an XSLT
engine that supports the evaluate() XSLT extension function. Your XSLT
engine does not support it.</xsl:message></xsl:otherwise></xsl:choose></xsl:template>