Blame xsl/common/common.xsl

Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
                xmlns:db="http://docbook.org/ns/docbook"
Packit 0f19cf
                xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
Packit 0f19cf
                xmlns:dyn="http://exslt.org/dynamic"
Packit 0f19cf
                xmlns:saxon="http://icl.com/saxon"
Packit 0f19cf
                exclude-result-prefixes="db doc dyn saxon"
Packit 0f19cf
                version='1.0'>
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
     Id
Packit 0f19cf
     ********************************************************************
Packit 0f19cf
Packit 0f19cf
     This file is part of the XSL DocBook Stylesheet distribution.
Packit 0f19cf
     See ../README or http://docbook.sf.net/release/xsl/current/ for
Packit 0f19cf
     copyright and other information.
Packit 0f19cf
Packit 0f19cf
     ******************************************************************** -->
Packit 0f19cf
Packit 0f19cf
<doc:reference xmlns="" xml:id="base">
Packit 0f19cf
  <info>
Packit 0f19cf
    <title>Common » Base Template Reference</title>
Packit 0f19cf
    <releaseinfo role="meta">
Packit 0f19cf
      $Id
Packit 0f19cf
    </releaseinfo>
Packit 0f19cf
  </info>
Packit 0f19cf
  
Packit 0f19cf
  <partintro xml:id="partintro">
Packit 0f19cf
    <title>Introduction</title>
Packit 0f19cf
    <para>This is technical reference documentation for the “base”
Packit 0f19cf
      set of common templates in the DocBook XSL Stylesheets.</para>
Packit 0f19cf
    <para>This is not intended to be user documentation. It is
Packit 0f19cf
      provided for developers writing customization layers for the
Packit 0f19cf
      stylesheets.</para>
Packit 0f19cf
  </partintro>
Packit 0f19cf
</doc:reference>
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
<xsl:preserve-space elements="*"/>
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
abstract affiliation anchor answer appendix area areaset areaspec artheader
Packit 0f19cf
article articleinfo audiodata audioobject author authorblurb authorgroup
Packit 0f19cf
beginpage bibliodiv biblioentry bibliography biblioset blockquote book
Packit 0f19cf
bookbiblio bookinfo callout calloutlist caption caution chapter
Packit 0f19cf
citerefentry cmdsynopsis co collab colophon colspec confgroup
Packit 0f19cf
copyright dedication docinfo editor entrytbl epigraph equation
Packit 0f19cf
example figure footnote footnoteref formalpara funcprototype
Packit 0f19cf
funcsynopsis glossary glossdef glossdiv glossentry glosslist graphicco
Packit 0f19cf
group highlights imagedata imageobject imageobjectco important index
Packit 0f19cf
indexdiv indexentry indexterm info informalequation informalexample
Packit 0f19cf
informalfigure informaltable inlineequation inlinemediaobject
Packit 0f19cf
itemizedlist itermset keycombo keywordset legalnotice listitem lot
Packit 0f19cf
mediaobject mediaobjectco menuchoice msg msgentry msgexplan msginfo
Packit 0f19cf
msgmain msgrel msgset msgsub msgtext note objectinfo
Packit 0f19cf
orderedlist othercredit part partintro preface printhistory procedure
Packit 0f19cf
programlistingco publisher qandadiv qandaentry qandaset question
Packit 0f19cf
refentry reference refmeta refnamediv refsection refsect1 refsect1info refsect2
Packit 0f19cf
refsect2info refsect3 refsect3info refsynopsisdiv refsynopsisdivinfo
Packit 0f19cf
revhistory revision row sbr screenco screenshot sect1 sect1info sect2
Packit 0f19cf
sect2info sect3 sect3info sect4 sect4info sect5 sect5info section
Packit 0f19cf
sectioninfo seglistitem segmentedlist seriesinfo set setindex setinfo
Packit 0f19cf
shortcut sidebar simplelist simplesect spanspec step subject
Packit 0f19cf
subjectset substeps synopfragment table tbody textobject tfoot tgroup
Packit 0f19cf
thead tip toc tocchap toclevel1 toclevel2 toclevel3 toclevel4
Packit 0f19cf
toclevel5 tocpart varargs variablelist varlistentry videodata
Packit 0f19cf
videoobject void warning subjectset
Packit 0f19cf
Packit 0f19cf
classsynopsis
Packit 0f19cf
constructorsynopsis
Packit 0f19cf
destructorsynopsis
Packit 0f19cf
fieldsynopsis
Packit 0f19cf
methodparam
Packit 0f19cf
methodsynopsis
Packit 0f19cf
ooclass
Packit 0f19cf
ooexception
Packit 0f19cf
oointerface
Packit 0f19cf
simplemsgentry
Packit 0f19cf
manvolnum
Packit 0f19cf
"/>
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
     stripping setup is not applied on the RTF built in stripNS mode, when
Packit 0f19cf
     xsl:imports are used in stylesheets, which is the case in dblatex
Packit 0f19cf
     -->
Packit 0f19cf
Packit 0f19cf
db:abstract db:affiliation db:anchor db:answer db:appendix db:area db:areaset
Packit 0f19cf
db:areaspec db:artheader db:article db:audiodata db:audioobject db:author
Packit 0f19cf
db:authorblurb db:authorgroup db:beginpage db:bibliodiv db:biblioentry
Packit 0f19cf
db:bibliography db:biblioset db:blockquote db:book db:bookbiblio
Packit 0f19cf
db:callout db:calloutlist db:caption db:caution db:chapter db:citerefentry
Packit 0f19cf
db:cmdsynopsis db:co db:collab db:colophon db:colspec db:confgroup db:copyright
Packit 0f19cf
db:dedication db:docinfo db:editor db:entrytbl db:epigraph db:equation
Packit 0f19cf
db:example db:figure db:footnote db:footnoteref db:formalpara db:funcprototype
Packit 0f19cf
db:funcsynopsis db:glossary db:glossdef db:glossdiv db:glossentry db:glosslist
Packit 0f19cf
db:graphicco db:group db:highlights db:imagedata db:imageobject
Packit 0f19cf
db:imageobjectco db:important db:index db:indexdiv db:indexentry db:indexterm
Packit 0f19cf
db:info db:informalequation db:informalexample db:informalfigure
Packit 0f19cf
db:informaltable db:inlineequation db:inlinemediaobject db:itemizedlist
Packit 0f19cf
db:itermset db:keycombo db:keywordset db:legalnotice db:listitem db:lot
Packit 0f19cf
db:mediaobject db:mediaobjectco db:menuchoice db:msg db:msgentry db:msgexplan
Packit 0f19cf
db:msginfo db:msgmain db:msgrel db:msgset db:msgsub db:msgtext db:note
Packit 0f19cf
db:orderedlist db:othercredit db:part db:partintro db:preface
Packit 0f19cf
db:printhistory db:procedure db:programlistingco db:publisher db:qandadiv
Packit 0f19cf
db:qandaentry db:qandaset db:question db:refentry db:reference db:refmeta
Packit 0f19cf
db:refnamediv db:refsection db:refsect1 db:refsect2 db:refsect3
Packit 0f19cf
db:refsynopsisdiv db:revhistory db:revision db:row db:sbr db:screenco
Packit 0f19cf
db:screenshot db:sect1 db:sect2 db:sect3 db:sect4 db:sect5 db:section
Packit 0f19cf
db:seglistitem db:segmentedlist db:seriesinfo db:set
Packit 0f19cf
db:setindex db:setinfo db:shortcut db:sidebar db:simplelist db:simplesect
Packit 0f19cf
db:spanspec db:step db:subject db:subjectset db:substeps db:synopfragment
Packit 0f19cf
db:table db:tbody db:textobject db:tfoot db:tgroup db:thead db:tip db:toc
Packit 0f19cf
db:tocchap db:toclevel1 db:toclevel2 db:toclevel3 db:toclevel4 db:toclevel5
Packit 0f19cf
db:tocpart db:varargs db:variablelist db:varlistentry db:videodata
Packit 0f19cf
db:videoobject db:void db:warning db:subjectset
Packit 0f19cf
db:classsynopsis
Packit 0f19cf
db:constructorsynopsis
Packit 0f19cf
db:destructorsynopsis
Packit 0f19cf
db:fieldsynopsis
Packit 0f19cf
db:methodparam
Packit 0f19cf
db:methodsynopsis
Packit 0f19cf
db:ooclass
Packit 0f19cf
db:ooexception
Packit 0f19cf
db:oointerface
Packit 0f19cf
db:simplemsgentry
Packit 0f19cf
db:manvolnum
Packit 0f19cf
"/>
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
<doc:template name="is.component" xmlns="">
Packit 0f19cf
<refpurpose>Tests if a given node is a component-level element</refpurpose>
Packit 0f19cf
Packit 0f19cf
<refdescription id="is.component-desc">
Packit 0f19cf
<para>This template returns '1' if the specified node is a component
Packit 0f19cf
(Chapter, Appendix, etc.), and '0' otherwise.</para>
Packit 0f19cf
</refdescription>
Packit 0f19cf
Packit 0f19cf
<refparameter id="is.component-params">
Packit 0f19cf
<variablelist>
Packit 0f19cf
<varlistentry><term>node</term>
Packit 0f19cf
<listitem>
Packit 0f19cf
<para>The node which is to be tested.</para>
Packit 0f19cf
</listitem>
Packit 0f19cf
</varlistentry>
Packit 0f19cf
</variablelist>
Packit 0f19cf
</refparameter>
Packit 0f19cf
Packit 0f19cf
<refreturn id="is.component-returns">
Packit 0f19cf
<para>This template returns '1' if the specified node is a component
Packit 0f19cf
(Chapter, Appendix, etc.), and '0' otherwise.</para>
Packit 0f19cf
</refreturn>
Packit 0f19cf
</doc:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template name="is.component">
Packit 0f19cf
  <xsl:param name="node" select="."/>
Packit 0f19cf
  <xsl:choose>
Packit 0f19cf
    
Packit 0f19cf
                    or local-name($node) = 'article'
Packit 0f19cf
                    or local-name($node) = 'chapter'
Packit 0f19cf
                    or local-name($node) = 'preface'
Packit 0f19cf
                    or local-name($node) = 'bibliography'
Packit 0f19cf
                    or local-name($node) = 'glossary'
Packit 0f19cf
                    or local-name($node) = 'index'">1</xsl:when>
Packit 0f19cf
    <xsl:otherwise>0</xsl:otherwise>
Packit 0f19cf
  </xsl:choose>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
<doc:template name="is.section" xmlns="">
Packit 0f19cf
<refpurpose>Tests if a given node is a section-level element</refpurpose>
Packit 0f19cf
Packit 0f19cf
<refdescription id="is.section-desc">
Packit 0f19cf
<para>This template returns '1' if the specified node is a section
Packit 0f19cf
(Section, Sect1, Sect2, etc.), and '0' otherwise.</para>
Packit 0f19cf
</refdescription>
Packit 0f19cf
Packit 0f19cf
<refparameter id="is.section-params">
Packit 0f19cf
<variablelist>
Packit 0f19cf
<varlistentry><term>node</term>
Packit 0f19cf
<listitem>
Packit 0f19cf
<para>The node which is to be tested.</para>
Packit 0f19cf
</listitem>
Packit 0f19cf
</varlistentry>
Packit 0f19cf
</variablelist>
Packit 0f19cf
</refparameter>
Packit 0f19cf
Packit 0f19cf
<refreturn id="is.section-returns">
Packit 0f19cf
<para>This template returns '1' if the specified node is a section
Packit 0f19cf
(Section, Sect1, Sect2, etc.), and '0' otherwise.</para>
Packit 0f19cf
</refreturn>
Packit 0f19cf
</doc:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template name="is.section">
Packit 0f19cf
  <xsl:param name="node" select="."/>
Packit 0f19cf
  <xsl:choose>
Packit 0f19cf
    
Packit 0f19cf
                    or local-name($node) = 'sect1'
Packit 0f19cf
                    or local-name($node) = 'sect2'
Packit 0f19cf
                    or local-name($node) = 'sect3'
Packit 0f19cf
                    or local-name($node) = 'sect4'
Packit 0f19cf
                    or local-name($node) = 'sect5'
Packit 0f19cf
                    or local-name($node) = 'refsect1'
Packit 0f19cf
                    or local-name($node) = 'refsect2'
Packit 0f19cf
                    or local-name($node) = 'refsect3'
Packit 0f19cf
                    or local-name($node) = 'simplesect'">1</xsl:when>
Packit 0f19cf
    <xsl:otherwise>0</xsl:otherwise>
Packit 0f19cf
  </xsl:choose>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
<doc:template name="section.level" xmlns="">
Packit 0f19cf
<refpurpose>Returns the hierarchical level of a section</refpurpose>
Packit 0f19cf
Packit 0f19cf
<refdescription id="section.level-desc">
Packit 0f19cf
<para>This template calculates the hierarchical level of a section.
Packit 0f19cf
The element <tag>sect1</tag> is at level 1, <tag>sect2</tag> is
Packit 0f19cf
at level 2, etc.</para>
Packit 0f19cf
Packit 0f19cf
<para>Recursive sections are calculated down to the fifth level.</para>
Packit 0f19cf
</refdescription>
Packit 0f19cf
Packit 0f19cf
<refparameter id="section.level-params">
Packit 0f19cf
<variablelist>
Packit 0f19cf
<varlistentry><term>node</term>
Packit 0f19cf
<listitem>
Packit 0f19cf
<para>The section node for which the level should be calculated.
Packit 0f19cf
Defaults to the context node.</para>
Packit 0f19cf
</listitem>
Packit 0f19cf
</varlistentry>
Packit 0f19cf
</variablelist>
Packit 0f19cf
</refparameter>
Packit 0f19cf
Packit 0f19cf
<refreturn id="section.level-returns">
Packit 0f19cf
<para>The section level, <quote>1</quote>, <quote>2</quote>, etc.
Packit 0f19cf
</para>
Packit 0f19cf
</refreturn>
Packit 0f19cf
</doc:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template name="section.level">
Packit 0f19cf
  <xsl:param name="node" select="."/>
Packit 0f19cf
  <xsl:choose>
Packit 0f19cf
    <xsl:when test="local-name($node)='sect1'">1</xsl:when>
Packit 0f19cf
    <xsl:when test="local-name($node)='sect2'">2</xsl:when>
Packit 0f19cf
    <xsl:when test="local-name($node)='sect3'">3</xsl:when>
Packit 0f19cf
    <xsl:when test="local-name($node)='sect4'">4</xsl:when>
Packit 0f19cf
    <xsl:when test="local-name($node)='sect5'">5</xsl:when>
Packit 0f19cf
    <xsl:when test="local-name($node)='section'">
Packit 0f19cf
      <xsl:choose>
Packit 0f19cf
        <xsl:when test="$node/../../../../../../section">6</xsl:when>
Packit 0f19cf
        <xsl:when test="$node/../../../../../section">5</xsl:when>
Packit 0f19cf
        <xsl:when test="$node/../../../../section">4</xsl:when>
Packit 0f19cf
        <xsl:when test="$node/../../../section">3</xsl:when>
Packit 0f19cf
        <xsl:when test="$node/../../section">2</xsl:when>
Packit 0f19cf
        <xsl:otherwise>1</xsl:otherwise>
Packit 0f19cf
      </xsl:choose>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    
Packit 0f19cf
                    local-name($node)='refsect2' or
Packit 0f19cf
                    local-name($node)='refsect3' or
Packit 0f19cf
                    local-name($node)='refsection' or
Packit 0f19cf
                    local-name($node)='refsynopsisdiv'">
Packit 0f19cf
      <xsl:call-template name="refentry.section.level">
Packit 0f19cf
        <xsl:with-param name="node" select="$node"/>
Packit 0f19cf
      </xsl:call-template>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:when test="local-name($node)='simplesect'">
Packit 0f19cf
      <xsl:choose>
Packit 0f19cf
        <xsl:when test="$node/../../sect1">2</xsl:when>
Packit 0f19cf
        <xsl:when test="$node/../../sect2">3</xsl:when>
Packit 0f19cf
        <xsl:when test="$node/../../sect3">4</xsl:when>
Packit 0f19cf
        <xsl:when test="$node/../../sect4">5</xsl:when>
Packit 0f19cf
        <xsl:when test="$node/../../sect5">5</xsl:when>
Packit 0f19cf
        <xsl:when test="$node/../../section">
Packit 0f19cf
          <xsl:choose>
Packit 0f19cf
            <xsl:when test="$node/../../../../../section">5</xsl:when>
Packit 0f19cf
            <xsl:when test="$node/../../../../section">4</xsl:when>
Packit 0f19cf
            <xsl:when test="$node/../../../section">3</xsl:when>
Packit 0f19cf
            <xsl:otherwise>2</xsl:otherwise>
Packit 0f19cf
          </xsl:choose>
Packit 0f19cf
        </xsl:when>
Packit 0f19cf
        <xsl:otherwise>1</xsl:otherwise>
Packit 0f19cf
      </xsl:choose>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:otherwise>1</xsl:otherwise>
Packit 0f19cf
  </xsl:choose>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
<doc:template name="qanda.section.level" xmlns="">
Packit 0f19cf
<refpurpose>Returns the hierarchical level of a QandASet</refpurpose>
Packit 0f19cf
Packit 0f19cf
<refdescription id="qanda.section.level-desc">
Packit 0f19cf
<para>This template calculates the hierarchical level of a QandASet.
Packit 0f19cf
</para>
Packit 0f19cf
</refdescription>
Packit 0f19cf
Packit 0f19cf
<refreturn id="qanda.section.level-returns">
Packit 0f19cf
<para>The level, <quote>1</quote>, <quote>2</quote>, etc.
Packit 0f19cf
</para>
Packit 0f19cf
</refreturn>
Packit 0f19cf
</doc:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template name="qanda.section.level">
Packit 0f19cf
  
Packit 0f19cf
                select="(ancestor::section
Packit 0f19cf
                         |ancestor::simplesect
Packit 0f19cf
                         |ancestor::sect5
Packit 0f19cf
                         |ancestor::sect4
Packit 0f19cf
                         |ancestor::sect3
Packit 0f19cf
                         |ancestor::sect2
Packit 0f19cf
                         |ancestor::sect1
Packit 0f19cf
                         |ancestor::refsect3
Packit 0f19cf
                         |ancestor::refsect2
Packit 0f19cf
                         |ancestor::refsect1)[last()]"/>
Packit 0f19cf
Packit 0f19cf
  <xsl:choose>
Packit 0f19cf
    <xsl:when test="count($section) = '0'">1</xsl:when>
Packit 0f19cf
    <xsl:otherwise>
Packit 0f19cf
      <xsl:variable name="slevel">
Packit 0f19cf
        <xsl:call-template name="section.level">
Packit 0f19cf
          <xsl:with-param name="node" select="$section"/>
Packit 0f19cf
        </xsl:call-template>
Packit 0f19cf
      </xsl:variable>
Packit 0f19cf
      <xsl:value-of select="$slevel + 1"/>
Packit 0f19cf
    </xsl:otherwise>
Packit 0f19cf
  </xsl:choose>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
<xsl:template name="refentry.section.level">
Packit 0f19cf
  <xsl:param name="node" select="."/>
Packit 0f19cf
Packit 0f19cf
  <xsl:variable name="RElevel">
Packit 0f19cf
    <xsl:call-template name="refentry.level">
Packit 0f19cf
      <xsl:with-param name="node" select="$node/ancestor::refentry[1]"/>
Packit 0f19cf
    </xsl:call-template>
Packit 0f19cf
  </xsl:variable>
Packit 0f19cf
Packit 0f19cf
  <xsl:variable name="levelinRE">
Packit 0f19cf
    <xsl:choose>
Packit 0f19cf
      <xsl:when test="local-name($node)='refsynopsisdiv'">1</xsl:when>
Packit 0f19cf
      <xsl:when test="local-name($node)='refsect1'">1</xsl:when>
Packit 0f19cf
      <xsl:when test="local-name($node)='refsect2'">2</xsl:when>
Packit 0f19cf
      <xsl:when test="local-name($node)='refsect3'">3</xsl:when>
Packit 0f19cf
      <xsl:when test="local-name($node)='refsection'">
Packit 0f19cf
        <xsl:choose>
Packit 0f19cf
          <xsl:when test="$node/../../../../../refsection">5</xsl:when>
Packit 0f19cf
          <xsl:when test="$node/../../../../refsection">4</xsl:when>
Packit 0f19cf
          <xsl:when test="$node/../../../refsection">3</xsl:when>
Packit 0f19cf
          <xsl:when test="$node/../../refsection">2</xsl:when>
Packit 0f19cf
          <xsl:otherwise>1</xsl:otherwise>
Packit 0f19cf
        </xsl:choose>
Packit 0f19cf
      </xsl:when>
Packit 0f19cf
    </xsl:choose>
Packit 0f19cf
  </xsl:variable>
Packit 0f19cf
Packit 0f19cf
  <xsl:value-of select="$levelinRE + $RElevel"/>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
<xsl:template name="refentry.level">
Packit 0f19cf
  <xsl:param name="node" select="."/>
Packit 0f19cf
  
Packit 0f19cf
                select="($node/ancestor::section |
Packit 0f19cf
                        $node/ancestor::sect1 |
Packit 0f19cf
                        $node/ancestor::sect2 |
Packit 0f19cf
                        $node/ancestor::sect3 |
Packit 0f19cf
                        $node/ancestor::sect4 |
Packit 0f19cf
                        $node/ancestor::sect5)[last()]"/>
Packit 0f19cf
Packit 0f19cf
  <xsl:choose>
Packit 0f19cf
    <xsl:when test="$container">
Packit 0f19cf
      <xsl:variable name="slevel">
Packit 0f19cf
        <xsl:call-template name="section.level">
Packit 0f19cf
          <xsl:with-param name="node" select="$container"/>
Packit 0f19cf
        </xsl:call-template>
Packit 0f19cf
      </xsl:variable>
Packit 0f19cf
      <xsl:value-of select="$slevel + 1"/>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:otherwise>1</xsl:otherwise>
Packit 0f19cf
  </xsl:choose>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template name="qandadiv.section.level">
Packit 0f19cf
  <xsl:variable name="section.level">
Packit 0f19cf
    <xsl:call-template name="qanda.section.level"/>
Packit 0f19cf
  </xsl:variable>
Packit 0f19cf
  <xsl:variable name="anc.divs" select="ancestor::qandadiv"/>
Packit 0f19cf
Packit 0f19cf
  <xsl:value-of select="count($anc.divs) + number($section.level)"/>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template name="question.answer.label">
Packit 0f19cf
  <xsl:variable name="deflabel">
Packit 0f19cf
    <xsl:choose>
Packit 0f19cf
      <xsl:when test="ancestor-or-self::*[@defaultlabel]">
Packit 0f19cf
        
Packit 0f19cf
                              /@defaultlabel"/>
Packit 0f19cf
      </xsl:when>
Packit 0f19cf
      <xsl:otherwise>
Packit 0f19cf
        <xsl:value-of select="$qanda.defaultlabel"/>
Packit 0f19cf
      </xsl:otherwise>
Packit 0f19cf
    </xsl:choose>
Packit 0f19cf
  </xsl:variable>
Packit 0f19cf
Packit 0f19cf
  <xsl:variable name="label" select="@label"/>
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
 (hnr      (hierarchical-number-recursive (normalize "qandadiv") node))
Packit 0f19cf
Packit 0f19cf
         (parsect  (ancestor-member node (section-element-list)))
Packit 0f19cf
Packit 0f19cf
         (defnum   (if (and %qanda-inherit-numeration% 
Packit 0f19cf
                            %section-autolabel%)
Packit 0f19cf
                       (if (node-list-empty? parsect)
Packit 0f19cf
                           (section-autolabel-prefix node)
Packit 0f19cf
                           (section-autolabel parsect))
Packit 0f19cf
                       ""))
Packit 0f19cf
Packit 0f19cf
         (hnumber  (let loop ((numlist hnr) (number defnum) 
Packit 0f19cf
                              (sep (if (equal? defnum "") "" ".")))
Packit 0f19cf
                     (if (null? numlist)
Packit 0f19cf
                         number
Packit 0f19cf
                         (loop (cdr numlist) 
Packit 0f19cf
                               (string-append number
Packit 0f19cf
                                              sep
Packit 0f19cf
                                              (number->string (car numlist)))
Packit 0f19cf
                               "."))))
Packit 0f19cf
         (cnumber  (child-number (parent node)))
Packit 0f19cf
         (number   (string-append hnumber 
Packit 0f19cf
                                  (if (equal? hnumber "")
Packit 0f19cf
                                      ""
Packit 0f19cf
                                      ".")
Packit 0f19cf
                                  (number->string cnumber))))
Packit 0f19cf
-->
Packit 0f19cf
Packit 0f19cf
  <xsl:choose>
Packit 0f19cf
    <xsl:when test="$deflabel = 'qanda'">
Packit 0f19cf
      <xsl:call-template name="gentext">
Packit 0f19cf
        <xsl:with-param name="key">
Packit 0f19cf
          <xsl:choose>
Packit 0f19cf
            <xsl:when test="local-name(.) = 'question'">question</xsl:when>
Packit 0f19cf
            <xsl:when test="local-name(.) = 'answer'">answer</xsl:when>
Packit 0f19cf
            <xsl:when test="local-name(.) = 'qandadiv'">qandadiv</xsl:when>
Packit 0f19cf
            <xsl:otherwise>qandaset</xsl:otherwise>
Packit 0f19cf
          </xsl:choose>
Packit 0f19cf
        </xsl:with-param>
Packit 0f19cf
      </xsl:call-template>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:when test="$deflabel = 'label'">
Packit 0f19cf
      <xsl:value-of select="$label"/>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    
Packit 0f19cf
                    and local-name(.) = 'question'">
Packit 0f19cf
      
Packit 0f19cf
                           mode="number"/>
Packit 0f19cf
      <xsl:choose>
Packit 0f19cf
        <xsl:when test="ancestor::qandadiv">
Packit 0f19cf
          
Packit 0f19cf
                               mode="number"/>
Packit 0f19cf
          
Packit 0f19cf
                               mode="number"/>
Packit 0f19cf
        </xsl:when>
Packit 0f19cf
        <xsl:otherwise>
Packit 0f19cf
          
Packit 0f19cf
                               mode="number"/>
Packit 0f19cf
        </xsl:otherwise>
Packit 0f19cf
      </xsl:choose>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:otherwise>
Packit 0f19cf
      
Packit 0f19cf
    </xsl:otherwise>
Packit 0f19cf
  </xsl:choose>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template match="qandaset" mode="number">
Packit 0f19cf
  
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template match="qandadiv" mode="number">
Packit 0f19cf
  <xsl:number level="multiple" from="qandaset" format="1."/>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template match="qandaentry" mode="number">
Packit 0f19cf
  <xsl:choose>
Packit 0f19cf
    <xsl:when test="ancestor::qandadiv">
Packit 0f19cf
      <xsl:number level="single" from="qandadiv" format="1."/>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:otherwise>
Packit 0f19cf
      <xsl:number level="single" from="qandaset" format="1."/>
Packit 0f19cf
    </xsl:otherwise>
Packit 0f19cf
  </xsl:choose>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
<xsl:template name="object.id">
Packit 0f19cf
  <xsl:param name="object" select="."/>
Packit 0f19cf
  <xsl:choose>
Packit 0f19cf
    <xsl:when test="$object/@id">
Packit 0f19cf
      <xsl:value-of select="$object/@id"/>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:when test="$object/@xml:id">
Packit 0f19cf
      <xsl:value-of select="$object/@xml:id"/>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:otherwise>
Packit 0f19cf
      <xsl:value-of select="generate-id($object)"/>
Packit 0f19cf
    </xsl:otherwise>
Packit 0f19cf
  </xsl:choose>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template name="person.name">
Packit 0f19cf
  
Packit 0f19cf
  <xsl:param name="node" select="."/>
Packit 0f19cf
Packit 0f19cf
  <xsl:variable name="style">
Packit 0f19cf
    <xsl:choose>
Packit 0f19cf
      <xsl:when test="$node/@role">
Packit 0f19cf
        <xsl:value-of select="$node/@role"/>
Packit 0f19cf
      </xsl:when>
Packit 0f19cf
      <xsl:otherwise>
Packit 0f19cf
        <xsl:call-template name="gentext.template">
Packit 0f19cf
          <xsl:with-param name="context" select="'styles'"/>
Packit 0f19cf
          <xsl:with-param name="name" select="'person-name'"/>
Packit 0f19cf
        </xsl:call-template>
Packit 0f19cf
      </xsl:otherwise>
Packit 0f19cf
    </xsl:choose>
Packit 0f19cf
  </xsl:variable>
Packit 0f19cf
Packit 0f19cf
  <xsl:choose>
Packit 0f19cf
    
Packit 0f19cf
    <xsl:when test="$node/personname">
Packit 0f19cf
      <xsl:call-template name="person.name">
Packit 0f19cf
        <xsl:with-param name="node" select="$node/personname"/>
Packit 0f19cf
      </xsl:call-template>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
Packit 0f19cf
    
Packit 0f19cf
    
Packit 0f19cf
    
Packit 0f19cf
    
Packit 0f19cf
    <xsl:when test="local-name($node)='corpauthor'">
Packit 0f19cf
      <xsl:apply-templates select="$node"/>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
Packit 0f19cf
    <xsl:otherwise>
Packit 0f19cf
      <xsl:choose>
Packit 0f19cf
        
Packit 0f19cf
        <xsl:when test="$node/self::personname and not($node/firstname or $node/honorific or $node/lineage or $node/othername or $node/surname)">
Packit 0f19cf
          <xsl:apply-templates select="$node/node()"/>
Packit 0f19cf
        </xsl:when>
Packit 0f19cf
        <xsl:when test="$style = 'family-given'">
Packit 0f19cf
          <xsl:call-template name="person.name.family-given">
Packit 0f19cf
            <xsl:with-param name="node" select="$node"/>
Packit 0f19cf
          </xsl:call-template>
Packit 0f19cf
        </xsl:when>
Packit 0f19cf
        <xsl:when test="$style = 'last-first'">
Packit 0f19cf
          <xsl:call-template name="person.name.last-first">
Packit 0f19cf
            <xsl:with-param name="node" select="$node"/>
Packit 0f19cf
          </xsl:call-template>
Packit 0f19cf
        </xsl:when>
Packit 0f19cf
        <xsl:otherwise>
Packit 0f19cf
          <xsl:call-template name="person.name.first-last">
Packit 0f19cf
            <xsl:with-param name="node" select="$node"/>
Packit 0f19cf
          </xsl:call-template>
Packit 0f19cf
        </xsl:otherwise>
Packit 0f19cf
      </xsl:choose>
Packit 0f19cf
    </xsl:otherwise>
Packit 0f19cf
  </xsl:choose>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template name="person.name.family-given">
Packit 0f19cf
  <xsl:param name="node" select="."/>
Packit 0f19cf
Packit 0f19cf
  
Packit 0f19cf
  
Packit 0f19cf
  <xsl:apply-templates select="$node//surname[1]"/>
Packit 0f19cf
Packit 0f19cf
  <xsl:if test="$node//surname and $node//firstname">
Packit 0f19cf
    <xsl:text> </xsl:text>
Packit 0f19cf
  </xsl:if>
Packit 0f19cf
Packit 0f19cf
  <xsl:apply-templates select="$node//firstname[1]"/>
Packit 0f19cf
Packit 0f19cf
  <xsl:text> [FAMILY Given]</xsl:text>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template name="person.name.last-first">
Packit 0f19cf
  <xsl:param name="node" select="."/>
Packit 0f19cf
Packit 0f19cf
  <xsl:apply-templates select="$node//surname[1]"/>
Packit 0f19cf
Packit 0f19cf
  <xsl:if test="$node//surname and $node//firstname">
Packit 0f19cf
    <xsl:text>, </xsl:text>
Packit 0f19cf
  </xsl:if>
Packit 0f19cf
Packit 0f19cf
  <xsl:apply-templates select="$node//firstname[1]"/>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template name="person.name.first-last">
Packit 0f19cf
  <xsl:param name="node" select="."/>
Packit 0f19cf
Packit 0f19cf
  <xsl:if test="$node//honorific">
Packit 0f19cf
    <xsl:apply-templates select="$node//honorific[1]"/>
Packit 0f19cf
    <xsl:value-of select="$punct.honorific"/>
Packit 0f19cf
  </xsl:if>
Packit 0f19cf
Packit 0f19cf
  <xsl:if test="$node//firstname">
Packit 0f19cf
    <xsl:if test="$node//honorific">
Packit 0f19cf
      <xsl:text> </xsl:text>
Packit 0f19cf
    </xsl:if>
Packit 0f19cf
    <xsl:apply-templates select="$node//firstname[1]"/>
Packit 0f19cf
  </xsl:if>
Packit 0f19cf
Packit 0f19cf
  <xsl:if test="$node//othername and $author.othername.in.middle != 0">
Packit 0f19cf
    <xsl:if test="$node//honorific or $node//firstname">
Packit 0f19cf
      <xsl:text> </xsl:text>
Packit 0f19cf
    </xsl:if>
Packit 0f19cf
    <xsl:apply-templates select="$node//othername[1]"/>
Packit 0f19cf
  </xsl:if>
Packit 0f19cf
Packit 0f19cf
  <xsl:if test="$node//surname">
Packit 0f19cf
    
Packit 0f19cf
                  or ($node//othername and $author.othername.in.middle != 0)">
Packit 0f19cf
      <xsl:text> </xsl:text>
Packit 0f19cf
    </xsl:if>
Packit 0f19cf
    <xsl:apply-templates select="$node//surname[1]"/>
Packit 0f19cf
  </xsl:if>
Packit 0f19cf
Packit 0f19cf
  <xsl:if test="$node//lineage">
Packit 0f19cf
    <xsl:text>, </xsl:text>
Packit 0f19cf
    <xsl:apply-templates select="$node//lineage[1]"/>
Packit 0f19cf
  </xsl:if>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template name="person.name.list">
Packit 0f19cf
  
Packit 0f19cf
       the current element. The current element must contain one or
Packit 0f19cf
       more AUTHORs, CORPAUTHORs, OTHERCREDITs, and/or EDITORs.
Packit 0f19cf
Packit 0f19cf
       John Doe
Packit 0f19cf
     or
Packit 0f19cf
       John Doe and Jane Doe
Packit 0f19cf
     or
Packit 0f19cf
       John Doe, Jane Doe, and A. Nonymous
Packit 0f19cf
  -->
Packit 0f19cf
  
Packit 0f19cf
             select="author|corpauthor|othercredit|editor"/>
Packit 0f19cf
  <xsl:param name="person.count" select="count($person.list)"/>
Packit 0f19cf
  <xsl:param name="count" select="1"/>
Packit 0f19cf
Packit 0f19cf
  <xsl:choose>
Packit 0f19cf
    <xsl:when test="$count > $person.count"></xsl:when>
Packit 0f19cf
    <xsl:otherwise>
Packit 0f19cf
      <xsl:call-template name="person.name">
Packit 0f19cf
        <xsl:with-param name="node" select="$person.list[position()=$count]"/>
Packit 0f19cf
      </xsl:call-template>
Packit 0f19cf
Packit 0f19cf
      <xsl:choose>
Packit 0f19cf
        <xsl:when test="$person.count = 2 and $count = 1">
Packit 0f19cf
          <xsl:call-template name="gentext.template">
Packit 0f19cf
            <xsl:with-param name="context" select="'authorgroup'"/>
Packit 0f19cf
            <xsl:with-param name="name" select="'sep2'"/>
Packit 0f19cf
          </xsl:call-template>
Packit 0f19cf
        </xsl:when>
Packit 0f19cf
        <xsl:when test="$person.count > 2 and $count+1 = $person.count">
Packit 0f19cf
          <xsl:call-template name="gentext.template">
Packit 0f19cf
            <xsl:with-param name="context" select="'authorgroup'"/>
Packit 0f19cf
            <xsl:with-param name="name" select="'seplast'"/>
Packit 0f19cf
          </xsl:call-template>
Packit 0f19cf
        </xsl:when>
Packit 0f19cf
        <xsl:when test="$count < $person.count">
Packit 0f19cf
          <xsl:call-template name="gentext.template">
Packit 0f19cf
            <xsl:with-param name="context" select="'authorgroup'"/>
Packit 0f19cf
            <xsl:with-param name="name" select="'sep'"/>
Packit 0f19cf
          </xsl:call-template>
Packit 0f19cf
        </xsl:when>
Packit 0f19cf
      </xsl:choose>
Packit 0f19cf
Packit 0f19cf
      <xsl:call-template name="person.name.list">
Packit 0f19cf
        <xsl:with-param name="person.list" select="$person.list"/>
Packit 0f19cf
        <xsl:with-param name="person.count" select="$person.count"/>
Packit 0f19cf
        <xsl:with-param name="count" select="$count+1"/>
Packit 0f19cf
      </xsl:call-template>
Packit 0f19cf
    </xsl:otherwise>
Packit 0f19cf
  </xsl:choose>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
     documentation for DocBook V3.0
Packit 0f19cf
-->
Packit 0f19cf
Packit 0f19cf
<xsl:variable name="arg.choice.opt.open.str">[</xsl:variable>
Packit 0f19cf
<xsl:variable name="arg.choice.opt.close.str">]</xsl:variable>
Packit 0f19cf
<xsl:variable name="arg.choice.req.open.str">{</xsl:variable>
Packit 0f19cf
<xsl:variable name="arg.choice.req.close.str">}</xsl:variable>
Packit 0f19cf
<xsl:variable name="arg.choice.plain.open.str"><xsl:text> </xsl:text></xsl:variable>
Packit 0f19cf
<xsl:variable name="arg.choice.plain.close.str"><xsl:text> </xsl:text></xsl:variable>
Packit 0f19cf
<xsl:variable name="arg.choice.def.open.str">[</xsl:variable>
Packit 0f19cf
<xsl:variable name="arg.choice.def.close.str">]</xsl:variable>
Packit 0f19cf
<xsl:variable name="arg.rep.repeat.str">...</xsl:variable>
Packit 0f19cf
<xsl:variable name="arg.rep.norepeat.str"></xsl:variable>
Packit 0f19cf
<xsl:variable name="arg.rep.def.str"></xsl:variable>
Packit 0f19cf
<xsl:variable name="arg.or.sep"> | </xsl:variable>
Packit 0f19cf
<xsl:variable name="cmdsynopsis.hanging.indent">4pi</xsl:variable>
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
<xsl:template name="xref.g.subst">
Packit 0f19cf
  <xsl:param name="string"></xsl:param>
Packit 0f19cf
  <xsl:param name="target" select="."/>
Packit 0f19cf
  <xsl:variable name="subst">%g</xsl:variable>
Packit 0f19cf
Packit 0f19cf
  <xsl:choose>
Packit 0f19cf
    <xsl:when test="contains($string, $subst)">
Packit 0f19cf
      <xsl:value-of select="substring-before($string, $subst)"/>
Packit 0f19cf
      <xsl:call-template name="gentext.element.name">
Packit 0f19cf
        <xsl:with-param name="element.name" select="local-name($target)"/>
Packit 0f19cf
      </xsl:call-template>
Packit 0f19cf
      <xsl:call-template name="xref.g.subst">
Packit 0f19cf
        
Packit 0f19cf
                        select="substring-after($string, $subst)"/>
Packit 0f19cf
        <xsl:with-param name="target" select="$target"/>
Packit 0f19cf
      </xsl:call-template>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:otherwise>
Packit 0f19cf
      <xsl:value-of select="$string"/>
Packit 0f19cf
    </xsl:otherwise>
Packit 0f19cf
  </xsl:choose>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template name="xref.t.subst">
Packit 0f19cf
  <xsl:param name="string"></xsl:param>
Packit 0f19cf
  <xsl:param name="target" select="."/>
Packit 0f19cf
  <xsl:variable name="subst">%t</xsl:variable>
Packit 0f19cf
Packit 0f19cf
  <xsl:choose>
Packit 0f19cf
    <xsl:when test="contains($string, $subst)">
Packit 0f19cf
      <xsl:call-template name="xref.g.subst">
Packit 0f19cf
        
Packit 0f19cf
                        select="substring-before($string, $subst)"/>
Packit 0f19cf
        <xsl:with-param name="target" select="$target"/>
Packit 0f19cf
      </xsl:call-template>
Packit 0f19cf
      <xsl:call-template name="title.xref">
Packit 0f19cf
        <xsl:with-param name="target" select="$target"/>
Packit 0f19cf
      </xsl:call-template>
Packit 0f19cf
      <xsl:call-template name="xref.t.subst">
Packit 0f19cf
        
Packit 0f19cf
                        select="substring-after($string, $subst)"/>
Packit 0f19cf
        <xsl:with-param name="target" select="$target"/>
Packit 0f19cf
      </xsl:call-template>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:otherwise>
Packit 0f19cf
      <xsl:call-template name="xref.g.subst">
Packit 0f19cf
        <xsl:with-param name="string" select="$string"/>
Packit 0f19cf
        <xsl:with-param name="target" select="$target"/>
Packit 0f19cf
      </xsl:call-template>
Packit 0f19cf
    </xsl:otherwise>
Packit 0f19cf
  </xsl:choose>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template name="xref.n.subst">
Packit 0f19cf
  <xsl:param name="string"></xsl:param>
Packit 0f19cf
  <xsl:param name="target" select="."/>
Packit 0f19cf
  <xsl:variable name="subst">%n</xsl:variable>
Packit 0f19cf
Packit 0f19cf
  <xsl:choose>
Packit 0f19cf
    <xsl:when test="contains($string, $subst)">
Packit 0f19cf
      <xsl:call-template name="xref.t.subst">
Packit 0f19cf
        
Packit 0f19cf
                        select="substring-before($string, $subst)"/>
Packit 0f19cf
        <xsl:with-param name="target" select="$target"/>
Packit 0f19cf
      </xsl:call-template>
Packit 0f19cf
      <xsl:call-template name="number.xref">
Packit 0f19cf
        <xsl:with-param name="target" select="$target"/>
Packit 0f19cf
      </xsl:call-template>
Packit 0f19cf
      <xsl:call-template name="xref.t.subst">
Packit 0f19cf
        
Packit 0f19cf
                        select="substring-after($string, $subst)"/>
Packit 0f19cf
        <xsl:with-param name="target" select="$target"/>
Packit 0f19cf
      </xsl:call-template>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:otherwise>
Packit 0f19cf
      <xsl:call-template name="xref.t.subst">
Packit 0f19cf
        <xsl:with-param name="string" select="$string"/>
Packit 0f19cf
        <xsl:with-param name="target" select="$target"/>
Packit 0f19cf
      </xsl:call-template>
Packit 0f19cf
    </xsl:otherwise>
Packit 0f19cf
  </xsl:choose>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template name="subst.xref.text">
Packit 0f19cf
  <xsl:param name="xref.text"></xsl:param>
Packit 0f19cf
  <xsl:param name="target" select="."/>
Packit 0f19cf
Packit 0f19cf
  <xsl:call-template name="xref.n.subst">
Packit 0f19cf
    <xsl:with-param name="string" select="$xref.text"/>
Packit 0f19cf
    <xsl:with-param name="target" select="$target"/>
Packit 0f19cf
  </xsl:call-template>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
-->
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
<xsl:template name="filename-basename">
Packit 0f19cf
  
Packit 0f19cf
  <xsl:param name="filename"></xsl:param>
Packit 0f19cf
  <xsl:param name="recurse" select="false()"/>
Packit 0f19cf
Packit 0f19cf
  <xsl:choose>
Packit 0f19cf
    <xsl:when test="substring-after($filename, '/') != ''">
Packit 0f19cf
      <xsl:call-template name="filename-basename">
Packit 0f19cf
        
Packit 0f19cf
                        select="substring-after($filename, '/')"/>
Packit 0f19cf
        <xsl:with-param name="recurse" select="true()"/>
Packit 0f19cf
      </xsl:call-template>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:otherwise>
Packit 0f19cf
      <xsl:value-of select="$filename"/>
Packit 0f19cf
    </xsl:otherwise>
Packit 0f19cf
  </xsl:choose>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template name="filename-extension">
Packit 0f19cf
  <xsl:param name="filename"></xsl:param>
Packit 0f19cf
  <xsl:param name="recurse" select="false()"/>
Packit 0f19cf
Packit 0f19cf
  
Packit 0f19cf
  <xsl:variable name="basefn">
Packit 0f19cf
    <xsl:choose>
Packit 0f19cf
      <xsl:when test="$recurse">
Packit 0f19cf
        <xsl:value-of select="$filename"/>
Packit 0f19cf
      </xsl:when>
Packit 0f19cf
      <xsl:otherwise>
Packit 0f19cf
        <xsl:call-template name="filename-basename">
Packit 0f19cf
          <xsl:with-param name="filename" select="$filename"/>
Packit 0f19cf
        </xsl:call-template>
Packit 0f19cf
      </xsl:otherwise>
Packit 0f19cf
    </xsl:choose>
Packit 0f19cf
  </xsl:variable>
Packit 0f19cf
Packit 0f19cf
  <xsl:choose>
Packit 0f19cf
    <xsl:when test="substring-after($basefn, '.') != ''">
Packit 0f19cf
      <xsl:call-template name="filename-extension">
Packit 0f19cf
        
Packit 0f19cf
                        select="substring-after($basefn, '.')"/>
Packit 0f19cf
        <xsl:with-param name="recurse" select="true()"/>
Packit 0f19cf
      </xsl:call-template>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:when test="$recurse">
Packit 0f19cf
      <xsl:value-of select="$basefn"/>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:otherwise></xsl:otherwise>
Packit 0f19cf
  </xsl:choose>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
<doc:template name="select.mediaobject" xmlns="">
Packit 0f19cf
<refpurpose>Selects and processes an appropriate media object from a list</refpurpose>
Packit 0f19cf
Packit 0f19cf
<refdescription id="select.mediaobject-desc">
Packit 0f19cf
<para>This template takes a list of media objects (usually the
Packit 0f19cf
children of a mediaobject or inlinemediaobject) and processes
Packit 0f19cf
the "right" object.</para>
Packit 0f19cf
Packit 0f19cf
<para>This template relies on a template named 
Packit 0f19cf
"select.mediaobject.index" to determine which object
Packit 0f19cf
in the list is appropriate.</para>
Packit 0f19cf
Packit 0f19cf
<para>If no acceptable object is located, nothing happens.</para>
Packit 0f19cf
</refdescription>
Packit 0f19cf
Packit 0f19cf
<refparameter id="select.mediaobject-params">
Packit 0f19cf
<variablelist>
Packit 0f19cf
<varlistentry><term>olist</term>
Packit 0f19cf
<listitem>
Packit 0f19cf
<para>The node list of potential objects to examine.</para>
Packit 0f19cf
</listitem>
Packit 0f19cf
</varlistentry>
Packit 0f19cf
</variablelist>
Packit 0f19cf
</refparameter>
Packit 0f19cf
Packit 0f19cf
<refreturn id="select.mediaobject-returns">
Packit 0f19cf
<para>Calls <xsl:apply-templates> on the selected object.</para>
Packit 0f19cf
</refreturn>
Packit 0f19cf
</doc:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template name="select.mediaobject">
Packit 0f19cf
  
Packit 0f19cf
             select="imageobject|imageobjectco
Packit 0f19cf
                     |videoobject|audioobject|textobject"/>
Packit 0f19cf
  
Packit 0f19cf
  <xsl:variable name="mediaobject.index">
Packit 0f19cf
    <xsl:call-template name="select.mediaobject.index">
Packit 0f19cf
      <xsl:with-param name="olist" select="$olist"/>
Packit 0f19cf
      <xsl:with-param name="count" select="1"/>
Packit 0f19cf
    </xsl:call-template>
Packit 0f19cf
  </xsl:variable>
Packit 0f19cf
Packit 0f19cf
  <xsl:if test="$mediaobject.index != ''">
Packit 0f19cf
    <xsl:apply-templates select="$olist[position() = $mediaobject.index]"/>
Packit 0f19cf
  </xsl:if>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
<doc:template name="select.mediaobject.index" xmlns="">
Packit 0f19cf
<refpurpose>Selects the position of the appropriate media object from a list</refpurpose>
Packit 0f19cf
Packit 0f19cf
<refdescription id="select.mediaobject.index-desc">
Packit 0f19cf
<para>This template takes a list of media objects (usually the
Packit 0f19cf
children of a mediaobject or inlinemediaobject) and determines
Packit 0f19cf
the "right" object. It returns the position of that object
Packit 0f19cf
to be used by the calling template.</para>
Packit 0f19cf
Packit 0f19cf
<para>If the parameter <parameter>use.role.for.mediaobject</parameter>
Packit 0f19cf
is nonzero, then it first checks for an object with
Packit 0f19cf
a role attribute of the appropriate value.  It takes the first
Packit 0f19cf
of those.  Otherwise, it takes the first acceptable object
Packit 0f19cf
through a recursive pass through the list.</para>
Packit 0f19cf
Packit 0f19cf
<para>This template relies on a template named "is.acceptable.mediaobject"
Packit 0f19cf
to determine if a given object is an acceptable graphic. The semantics
Packit 0f19cf
of media objects is that the first acceptable graphic should be used.
Packit 0f19cf
</para>
Packit 0f19cf
Packit 0f19cf
<para>If no acceptable object is located, no index is returned.</para>
Packit 0f19cf
</refdescription>
Packit 0f19cf
Packit 0f19cf
<refparameter id="select.mediaobject.index-params">
Packit 0f19cf
<variablelist>
Packit 0f19cf
<varlistentry><term>olist</term>
Packit 0f19cf
<listitem>
Packit 0f19cf
<para>The node list of potential objects to examine.</para>
Packit 0f19cf
</listitem>
Packit 0f19cf
</varlistentry>
Packit 0f19cf
<varlistentry><term>count</term>
Packit 0f19cf
<listitem>
Packit 0f19cf
<para>The position in the list currently being considered by the 
Packit 0f19cf
recursive process.</para>
Packit 0f19cf
</listitem>
Packit 0f19cf
</varlistentry>
Packit 0f19cf
</variablelist>
Packit 0f19cf
</refparameter>
Packit 0f19cf
Packit 0f19cf
<refreturn id="select.mediaobject.index-returns">
Packit 0f19cf
<para>Returns the position in the original list of the selected object.</para>
Packit 0f19cf
</refreturn>
Packit 0f19cf
</doc:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template name="select.mediaobject.index">
Packit 0f19cf
  
Packit 0f19cf
             select="imageobject|imageobjectco
Packit 0f19cf
                     |videoobject|audioobject|textobject"/>
Packit 0f19cf
  <xsl:param name="count">1</xsl:param>
Packit 0f19cf
Packit 0f19cf
  <xsl:choose>
Packit 0f19cf
    
Packit 0f19cf
    
Packit 0f19cf
               and $preferred.mediaobject.role != ''
Packit 0f19cf
               and $olist[@role = $preferred.mediaobject.role]"> 
Packit 0f19cf
      
Packit 0f19cf
      
Packit 0f19cf
      <xsl:for-each select="$olist">
Packit 0f19cf
        
Packit 0f19cf
             not(preceding-sibling::*[@role = $preferred.mediaobject.role])"> 
Packit 0f19cf
          <xsl:value-of select="position()"/> 
Packit 0f19cf
        </xsl:if>
Packit 0f19cf
      </xsl:for-each>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
Packit 0f19cf
    
Packit 0f19cf
               and $olist[@role = $stylesheet.result.type]">
Packit 0f19cf
      
Packit 0f19cf
      <xsl:for-each select="$olist">
Packit 0f19cf
        
Packit 0f19cf
              not(preceding-sibling::*[@role = $stylesheet.result.type])"> 
Packit 0f19cf
          <xsl:value-of select="position()"/> 
Packit 0f19cf
        </xsl:if>
Packit 0f19cf
      </xsl:for-each>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    
Packit 0f19cf
    
Packit 0f19cf
               and $stylesheet.result.type = 'xhtml'
Packit 0f19cf
               and $olist[@role = 'html']">
Packit 0f19cf
      
Packit 0f19cf
      <xsl:for-each select="$olist">
Packit 0f19cf
        
Packit 0f19cf
              not(preceding-sibling::*[@role = 'html'])"> 
Packit 0f19cf
          <xsl:value-of select="position()"/> 
Packit 0f19cf
        </xsl:if>
Packit 0f19cf
      </xsl:for-each>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
Packit 0f19cf
    
Packit 0f19cf
    <xsl:when test="count($olist) = 1 and $count = 1">
Packit 0f19cf
      <xsl:value-of select="$count"/> 
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
Packit 0f19cf
    <xsl:otherwise>
Packit 0f19cf
      
Packit 0f19cf
      <xsl:if test="$count <= count($olist)">
Packit 0f19cf
        <xsl:variable name="object" select="$olist[position()=$count]"/>
Packit 0f19cf
    
Packit 0f19cf
        <xsl:variable name="useobject">
Packit 0f19cf
          <xsl:choose>
Packit 0f19cf
            
Packit 0f19cf
            
Packit 0f19cf
                            and $object/@role='tex' and $stylesheet.result.type = 'fo'
Packit 0f19cf
                            and $tex.math.in.alt != ''">
Packit 0f19cf
              <xsl:text>1</xsl:text> 
Packit 0f19cf
            </xsl:when>
Packit 0f19cf
            
Packit 0f19cf
            <xsl:when test="local-name($object)='textobject' and $object/phrase">
Packit 0f19cf
              <xsl:text>0</xsl:text>
Packit 0f19cf
            </xsl:when>
Packit 0f19cf
            
Packit 0f19cf
                            and $object/ancestor::equation ">
Packit 0f19cf
            
Packit 0f19cf
                 for equation image -->
Packit 0f19cf
              <xsl:text>0</xsl:text>
Packit 0f19cf
            </xsl:when>
Packit 0f19cf
            
Packit 0f19cf
            
Packit 0f19cf
                            and $object[not(@role) or @role!='tex']">
Packit 0f19cf
              <xsl:text>1</xsl:text>
Packit 0f19cf
            </xsl:when>
Packit 0f19cf
            
Packit 0f19cf
                 and there is math in alt element -->
Packit 0f19cf
            
Packit 0f19cf
                            $object/ancestor::equation/alt[@role='tex']
Packit 0f19cf
                            and $stylesheet.result.type = 'fo'
Packit 0f19cf
                            and $tex.math.in.alt != ''">
Packit 0f19cf
              <xsl:text>0</xsl:text>
Packit 0f19cf
            </xsl:when>
Packit 0f19cf
            
Packit 0f19cf
            <xsl:when test="$count = 1 and count($olist) = 1">
Packit 0f19cf
               <xsl:text>1</xsl:text>
Packit 0f19cf
            </xsl:when>
Packit 0f19cf
            
Packit 0f19cf
            <xsl:otherwise>
Packit 0f19cf
              <xsl:choose>
Packit 0f19cf
                
Packit 0f19cf
                <xsl:when test="local-name($object) = 'imageobjectco'">
Packit 0f19cf
                  <xsl:call-template name="is.acceptable.mediaobject">
Packit 0f19cf
                    <xsl:with-param name="object" select="$object/imageobject"/>
Packit 0f19cf
                  </xsl:call-template>
Packit 0f19cf
                </xsl:when>
Packit 0f19cf
                <xsl:otherwise>
Packit 0f19cf
                  <xsl:call-template name="is.acceptable.mediaobject">
Packit 0f19cf
                    <xsl:with-param name="object" select="$object"/>
Packit 0f19cf
                  </xsl:call-template>
Packit 0f19cf
                </xsl:otherwise>
Packit 0f19cf
              </xsl:choose>
Packit 0f19cf
            </xsl:otherwise>
Packit 0f19cf
          </xsl:choose>
Packit 0f19cf
        </xsl:variable>
Packit 0f19cf
    
Packit 0f19cf
        <xsl:choose>
Packit 0f19cf
          <xsl:when test="$useobject='1'">
Packit 0f19cf
            <xsl:value-of select="$count"/>
Packit 0f19cf
          </xsl:when>
Packit 0f19cf
          <xsl:otherwise>
Packit 0f19cf
            <xsl:call-template name="select.mediaobject.index">
Packit 0f19cf
              <xsl:with-param name="olist" select="$olist"/>
Packit 0f19cf
              <xsl:with-param name="count" select="$count + 1"/>
Packit 0f19cf
            </xsl:call-template>
Packit 0f19cf
          </xsl:otherwise>
Packit 0f19cf
        </xsl:choose>
Packit 0f19cf
      </xsl:if>
Packit 0f19cf
    </xsl:otherwise>
Packit 0f19cf
  </xsl:choose>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
<doc:template name="is.acceptable.mediaobject" xmlns="">
Packit 0f19cf
<refpurpose>Returns '1' if the specified media object is recognized</refpurpose>
Packit 0f19cf
Packit 0f19cf
<refdescription id="is.acceptable.mediaobject-desc">
Packit 0f19cf
<para>This template examines a media object and returns '1' if the
Packit 0f19cf
object is recognized as a graphic.</para>
Packit 0f19cf
</refdescription>
Packit 0f19cf
Packit 0f19cf
<refparameter id="is.acceptable.mediaobject-params">
Packit 0f19cf
<variablelist>
Packit 0f19cf
<varlistentry><term>object</term>
Packit 0f19cf
<listitem>
Packit 0f19cf
<para>The media object to consider.</para>
Packit 0f19cf
</listitem>
Packit 0f19cf
</varlistentry>
Packit 0f19cf
</variablelist>
Packit 0f19cf
</refparameter>
Packit 0f19cf
Packit 0f19cf
<refreturn id="is.acceptable.mediaobject-returns">
Packit 0f19cf
<para>0 or 1</para>
Packit 0f19cf
</refreturn>
Packit 0f19cf
</doc:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template name="is.acceptable.mediaobject">
Packit 0f19cf
  <xsl:param name="object"></xsl:param>
Packit 0f19cf
Packit 0f19cf
  <xsl:variable name="filename">
Packit 0f19cf
    <xsl:call-template name="mediaobject.filename">
Packit 0f19cf
      <xsl:with-param name="object" select="$object"/>
Packit 0f19cf
    </xsl:call-template>
Packit 0f19cf
  </xsl:variable>
Packit 0f19cf
Packit 0f19cf
  <xsl:variable name="ext">
Packit 0f19cf
    <xsl:call-template name="filename-extension">
Packit 0f19cf
      <xsl:with-param name="filename" select="$filename"/>
Packit 0f19cf
    </xsl:call-template>
Packit 0f19cf
  </xsl:variable>
Packit 0f19cf
Packit 0f19cf
  
Packit 0f19cf
  
Packit 0f19cf
                                    |$object/imagedata
Packit 0f19cf
                                    |$object/audiodata"/>
Packit 0f19cf
Packit 0f19cf
  <xsl:variable name="format" select="$data/@format"/>
Packit 0f19cf
Packit 0f19cf
  <xsl:variable name="graphic.format">
Packit 0f19cf
    <xsl:if test="$format">
Packit 0f19cf
      <xsl:call-template name="is.graphic.format">
Packit 0f19cf
        <xsl:with-param name="format" select="$format"/>
Packit 0f19cf
      </xsl:call-template>
Packit 0f19cf
    </xsl:if>
Packit 0f19cf
  </xsl:variable>
Packit 0f19cf
Packit 0f19cf
  <xsl:variable name="graphic.ext">
Packit 0f19cf
    <xsl:if test="$ext">
Packit 0f19cf
      <xsl:call-template name="is.graphic.extension">
Packit 0f19cf
        <xsl:with-param name="ext" select="$ext"/>
Packit 0f19cf
      </xsl:call-template>
Packit 0f19cf
    </xsl:if>
Packit 0f19cf
  </xsl:variable>
Packit 0f19cf
Packit 0f19cf
  <xsl:choose>
Packit 0f19cf
    <xsl:when test="$use.svg = 0 and $format = 'SVG'">0</xsl:when>
Packit 0f19cf
    
Packit 0f19cf
              test="$use.svg != 0 and $object/svg:*">1</xsl:when>
Packit 0f19cf
    <xsl:when test="$graphic.format = '1'">1</xsl:when>
Packit 0f19cf
    <xsl:when test="$graphic.ext = '1'">1</xsl:when>
Packit 0f19cf
    <xsl:otherwise>0</xsl:otherwise>
Packit 0f19cf
  </xsl:choose>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template name="mediaobject.filename">
Packit 0f19cf
  <xsl:param name="object"></xsl:param>
Packit 0f19cf
Packit 0f19cf
  
Packit 0f19cf
                                    |$object/imagedata
Packit 0f19cf
                                    |$object/audiodata
Packit 0f19cf
                                    |$object"/>
Packit 0f19cf
Packit 0f19cf
  <xsl:variable name="filename">
Packit 0f19cf
    <xsl:choose>
Packit 0f19cf
      <xsl:when test="$data[@fileref]">
Packit 0f19cf
        <xsl:apply-templates select="$data/@fileref"/>
Packit 0f19cf
      </xsl:when>
Packit 0f19cf
      <xsl:when test="$data[@entityref]">
Packit 0f19cf
        <xsl:value-of select="unparsed-entity-uri($data/@entityref)"/>
Packit 0f19cf
      </xsl:when>
Packit 0f19cf
      <xsl:otherwise></xsl:otherwise>
Packit 0f19cf
    </xsl:choose>
Packit 0f19cf
  </xsl:variable>
Packit 0f19cf
Packit 0f19cf
  <xsl:variable name="real.ext">
Packit 0f19cf
    <xsl:call-template name="filename-extension">
Packit 0f19cf
      <xsl:with-param name="filename" select="$filename"/>
Packit 0f19cf
    </xsl:call-template>
Packit 0f19cf
  </xsl:variable>
Packit 0f19cf
Packit 0f19cf
  <xsl:variable name="ext">
Packit 0f19cf
    <xsl:choose>
Packit 0f19cf
      <xsl:when test="$real.ext != ''">
Packit 0f19cf
        <xsl:value-of select="$real.ext"/>
Packit 0f19cf
      </xsl:when>
Packit 0f19cf
      <xsl:otherwise>
Packit 0f19cf
        <xsl:value-of select="$graphic.default.extension"/>
Packit 0f19cf
      </xsl:otherwise>
Packit 0f19cf
    </xsl:choose>
Packit 0f19cf
  </xsl:variable>
Packit 0f19cf
Packit 0f19cf
  <xsl:variable name="graphic.ext">
Packit 0f19cf
    <xsl:call-template name="is.graphic.extension">
Packit 0f19cf
      <xsl:with-param name="ext" select="$ext"/>
Packit 0f19cf
    </xsl:call-template>
Packit 0f19cf
  </xsl:variable>
Packit 0f19cf
Packit 0f19cf
  <xsl:choose>
Packit 0f19cf
    <xsl:when test="$real.ext = ''">
Packit 0f19cf
      <xsl:choose>
Packit 0f19cf
        <xsl:when test="$ext != ''">
Packit 0f19cf
          <xsl:value-of select="$filename"/>
Packit 0f19cf
          <xsl:text>.</xsl:text>
Packit 0f19cf
          <xsl:value-of select="$ext"/>
Packit 0f19cf
        </xsl:when>
Packit 0f19cf
        <xsl:otherwise>
Packit 0f19cf
          <xsl:value-of select="$filename"/>
Packit 0f19cf
        </xsl:otherwise>
Packit 0f19cf
      </xsl:choose>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:when test="not($graphic.ext)">
Packit 0f19cf
      <xsl:choose>
Packit 0f19cf
        <xsl:when test="$graphic.default.extension != ''">
Packit 0f19cf
          <xsl:value-of select="$filename"/>
Packit 0f19cf
          <xsl:text>.</xsl:text>
Packit 0f19cf
          <xsl:value-of select="$graphic.default.extension"/>
Packit 0f19cf
        </xsl:when>
Packit 0f19cf
        <xsl:otherwise>
Packit 0f19cf
          <xsl:value-of select="$filename"/>
Packit 0f19cf
        </xsl:otherwise>
Packit 0f19cf
      </xsl:choose>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:otherwise>
Packit 0f19cf
      <xsl:value-of select="$filename"/>
Packit 0f19cf
    </xsl:otherwise>
Packit 0f19cf
  </xsl:choose>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
<doc:template name="check.id.unique" xmlns="">
Packit 0f19cf
<refpurpose>Warn users about references to non-unique IDs</refpurpose>
Packit 0f19cf
<refdescription id="check.id.unique-desc">
Packit 0f19cf
<para>If passed an ID in <varname>linkend</varname>,
Packit 0f19cf
<function>check.id.unique</function> prints
Packit 0f19cf
a warning message to the user if either the ID does not exist or
Packit 0f19cf
the ID is not unique.</para>
Packit 0f19cf
</refdescription>
Packit 0f19cf
</doc:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template name="check.id.unique">
Packit 0f19cf
  <xsl:param name="linkend"></xsl:param>
Packit 0f19cf
  <xsl:if test="$linkend != ''">
Packit 0f19cf
    <xsl:variable name="targets" select="key('id',$linkend)"/>
Packit 0f19cf
    <xsl:variable name="target" select="$targets[1]"/>
Packit 0f19cf
Packit 0f19cf
    <xsl:if test="count($targets)=0">
Packit 0f19cf
      <xsl:message>
Packit 0f19cf
        <xsl:text>Error: no ID for constraint linkend: </xsl:text>
Packit 0f19cf
        <xsl:value-of select="$linkend"/>
Packit 0f19cf
        <xsl:text>.</xsl:text>
Packit 0f19cf
      </xsl:message>
Packit 0f19cf
      
Packit 0f19cf
      <xsl:message>
Packit 0f19cf
        <xsl:text>If the ID exists in your document, did your </xsl:text>
Packit 0f19cf
        <xsl:text>XSLT Processor load the DTD?</xsl:text>
Packit 0f19cf
      </xsl:message>
Packit 0f19cf
      -->
Packit 0f19cf
    </xsl:if>
Packit 0f19cf
Packit 0f19cf
    <xsl:if test="count($targets)>1">
Packit 0f19cf
      <xsl:message>
Packit 0f19cf
        <xsl:text>Warning: multiple "IDs" for constraint linkend: </xsl:text>
Packit 0f19cf
        <xsl:value-of select="$linkend"/>
Packit 0f19cf
        <xsl:text>.</xsl:text>
Packit 0f19cf
      </xsl:message>
Packit 0f19cf
    </xsl:if>
Packit 0f19cf
  </xsl:if>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
<doc:template name="check.idref.targets" xmlns="">
Packit 0f19cf
<refpurpose>Warn users about incorrectly typed references</refpurpose>
Packit 0f19cf
<refdescription id="check.idref.targets-desc">
Packit 0f19cf
<para>If passed an ID in <varname>linkend</varname>,
Packit 0f19cf
<function>check.idref.targets</function> makes sure that the element
Packit 0f19cf
pointed to by the link is one of the elements listed in
Packit 0f19cf
<varname>element-list</varname> and warns the user otherwise.</para>
Packit 0f19cf
</refdescription>
Packit 0f19cf
</doc:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template name="check.idref.targets">
Packit 0f19cf
  <xsl:param name="linkend"></xsl:param>
Packit 0f19cf
  <xsl:param name="element-list"></xsl:param>
Packit 0f19cf
  <xsl:if test="$linkend != ''">
Packit 0f19cf
    <xsl:variable name="targets" select="key('id',$linkend)"/>
Packit 0f19cf
    <xsl:variable name="target" select="$targets[1]"/>
Packit 0f19cf
Packit 0f19cf
    <xsl:if test="count($target) > 0">
Packit 0f19cf
      <xsl:if test="not(contains(concat(' ', $element-list, ' '), local-name($target)))">
Packit 0f19cf
        <xsl:message>
Packit 0f19cf
          <xsl:text>Error: linkend (</xsl:text>
Packit 0f19cf
          <xsl:value-of select="$linkend"/>
Packit 0f19cf
          <xsl:text>) points to "</xsl:text>
Packit 0f19cf
          <xsl:value-of select="local-name($target)"/>
Packit 0f19cf
          <xsl:text>" not (one of): </xsl:text>
Packit 0f19cf
          <xsl:value-of select="$element-list"/>
Packit 0f19cf
        </xsl:message>
Packit 0f19cf
      </xsl:if>
Packit 0f19cf
    </xsl:if>
Packit 0f19cf
  </xsl:if>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
<xsl:param name="procedure.step.numeration.formats" select="'1aiAI'"/>
Packit 0f19cf
Packit 0f19cf
<xsl:template name="procedure.step.numeration">
Packit 0f19cf
  <xsl:param name="context" select="."/>
Packit 0f19cf
  
Packit 0f19cf
                select="string-length($procedure.step.numeration.formats)"/>
Packit 0f19cf
  <xsl:choose>
Packit 0f19cf
    <xsl:when test="local-name($context) = 'substeps'">
Packit 0f19cf
      
Packit 0f19cf
                    select="count($context/ancestor::substeps)"/>
Packit 0f19cf
      <xsl:variable name="sstype" select="($ssdepth mod $format.length)+2"/>
Packit 0f19cf
      <xsl:choose>
Packit 0f19cf
        <xsl:when test="$sstype > $format.length">
Packit 0f19cf
          <xsl:value-of select="substring($procedure.step.numeration.formats,1,1)"/>
Packit 0f19cf
        </xsl:when>
Packit 0f19cf
        <xsl:otherwise>
Packit 0f19cf
          <xsl:value-of select="substring($procedure.step.numeration.formats,$sstype,1)"/>
Packit 0f19cf
        </xsl:otherwise>
Packit 0f19cf
      </xsl:choose>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:when test="local-name($context) = 'step'">
Packit 0f19cf
      
Packit 0f19cf
                    select="count($context/ancestor::substeps)"/>
Packit 0f19cf
      <xsl:variable name="stype" select="($sdepth mod $format.length)+1"/>
Packit 0f19cf
      <xsl:value-of select="substring($procedure.step.numeration.formats,$stype,1)"/>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:otherwise>
Packit 0f19cf
      <xsl:message>
Packit 0f19cf
        <xsl:text>Unexpected context in procedure.step.numeration: </xsl:text>
Packit 0f19cf
        <xsl:value-of select="local-name($context)"/>
Packit 0f19cf
      </xsl:message>
Packit 0f19cf
    </xsl:otherwise>
Packit 0f19cf
  </xsl:choose>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template match="step" mode="number">
Packit 0f19cf
  <xsl:param name="rest" select="''"/>
Packit 0f19cf
  <xsl:param name="recursive" select="1"/>
Packit 0f19cf
  <xsl:variable name="format">
Packit 0f19cf
    <xsl:call-template name="procedure.step.numeration"/>
Packit 0f19cf
  </xsl:variable>
Packit 0f19cf
  <xsl:variable name="num">
Packit 0f19cf
    <xsl:number count="step" format="{$format}"/>
Packit 0f19cf
  </xsl:variable>
Packit 0f19cf
  <xsl:choose>
Packit 0f19cf
    <xsl:when test="$recursive != 0 and ancestor::step">
Packit 0f19cf
      <xsl:apply-templates select="ancestor::step[1]" mode="number">
Packit 0f19cf
        <xsl:with-param name="rest" select="concat('.', $num, $rest)"/>
Packit 0f19cf
      </xsl:apply-templates>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:otherwise>
Packit 0f19cf
      <xsl:value-of select="concat($num, $rest)"/>
Packit 0f19cf
    </xsl:otherwise>
Packit 0f19cf
  </xsl:choose>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
<xsl:template name="output-orderedlist-starting-number">
Packit 0f19cf
  <xsl:param name="list"/>
Packit 0f19cf
  <xsl:param name="pi-start"/>
Packit 0f19cf
  <xsl:choose>
Packit 0f19cf
    <xsl:when test="not($list/@continuation = 'continues')">
Packit 0f19cf
      <xsl:choose>
Packit 0f19cf
        <xsl:when test="@startingnumber">
Packit 0f19cf
          <xsl:value-of select="@startingnumber"/>
Packit 0f19cf
        </xsl:when>
Packit 0f19cf
        <xsl:when test="$pi-start != ''">
Packit 0f19cf
          <xsl:value-of select="$pi-start"/>
Packit 0f19cf
        </xsl:when>
Packit 0f19cf
        <xsl:otherwise>1</xsl:otherwise>
Packit 0f19cf
      </xsl:choose>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:otherwise>
Packit 0f19cf
      
Packit 0f19cf
        select="$list/preceding::orderedlist[1]"/>
Packit 0f19cf
      <xsl:choose>
Packit 0f19cf
        <xsl:when test="count($prevlist) = 0">2</xsl:when>
Packit 0f19cf
        <xsl:otherwise>
Packit 0f19cf
          <xsl:variable name="prevlength" select="count($prevlist/listitem)"/>
Packit 0f19cf
          <xsl:variable name="prevstart">
Packit 0f19cf
            <xsl:call-template name="orderedlist-starting-number">
Packit 0f19cf
              <xsl:with-param name="list" select="$prevlist"/>
Packit 0f19cf
            </xsl:call-template>
Packit 0f19cf
          </xsl:variable>
Packit 0f19cf
          <xsl:value-of select="$prevstart + $prevlength"/>
Packit 0f19cf
        </xsl:otherwise>
Packit 0f19cf
      </xsl:choose>
Packit 0f19cf
    </xsl:otherwise>
Packit 0f19cf
  </xsl:choose>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template name="orderedlist-item-number">
Packit 0f19cf
  
Packit 0f19cf
  <xsl:param name="node" select="."/>
Packit 0f19cf
  <xsl:choose>
Packit 0f19cf
    <xsl:when test="$node/@override">
Packit 0f19cf
      <xsl:value-of select="$node/@override"/>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:when test="$node/preceding-sibling::listitem">
Packit 0f19cf
      <xsl:variable name="pnum">
Packit 0f19cf
        <xsl:call-template name="orderedlist-item-number">
Packit 0f19cf
          <xsl:with-param name="node" select="$node/preceding-sibling::listitem[1]"/>
Packit 0f19cf
        </xsl:call-template>
Packit 0f19cf
      </xsl:variable>
Packit 0f19cf
      <xsl:value-of select="$pnum + 1"/>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:otherwise>
Packit 0f19cf
      <xsl:call-template name="orderedlist-starting-number">
Packit 0f19cf
        <xsl:with-param name="list" select="parent::*"/>
Packit 0f19cf
      </xsl:call-template>
Packit 0f19cf
    </xsl:otherwise>
Packit 0f19cf
  </xsl:choose>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template name="next.numeration">
Packit 0f19cf
  <xsl:param name="numeration" select="'default'"/>
Packit 0f19cf
  <xsl:choose>
Packit 0f19cf
    
Packit 0f19cf
    <xsl:when test="$numeration = 'arabic'">loweralpha</xsl:when>
Packit 0f19cf
    <xsl:when test="$numeration = 'loweralpha'">lowerroman</xsl:when>
Packit 0f19cf
    <xsl:when test="$numeration = 'lowerroman'">upperalpha</xsl:when>
Packit 0f19cf
    <xsl:when test="$numeration = 'upperalpha'">upperroman</xsl:when>
Packit 0f19cf
    <xsl:when test="$numeration = 'upperroman'">arabic</xsl:when>
Packit 0f19cf
    <xsl:otherwise>arabic</xsl:otherwise>
Packit 0f19cf
  </xsl:choose>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template name="list.numeration">
Packit 0f19cf
  <xsl:param name="node" select="."/>
Packit 0f19cf
Packit 0f19cf
  <xsl:choose>
Packit 0f19cf
    <xsl:when test="$node/@numeration">
Packit 0f19cf
      <xsl:value-of select="$node/@numeration"/>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:otherwise>
Packit 0f19cf
      <xsl:choose>
Packit 0f19cf
        <xsl:when test="$node/ancestor::orderedlist">
Packit 0f19cf
          <xsl:call-template name="next.numeration">
Packit 0f19cf
            <xsl:with-param name="numeration">
Packit 0f19cf
              <xsl:call-template name="list.numeration">
Packit 0f19cf
                <xsl:with-param name="node" select="$node/ancestor::orderedlist[1]"/>
Packit 0f19cf
              </xsl:call-template>
Packit 0f19cf
            </xsl:with-param>
Packit 0f19cf
          </xsl:call-template>
Packit 0f19cf
        </xsl:when>
Packit 0f19cf
        <xsl:otherwise>
Packit 0f19cf
          <xsl:call-template name="next.numeration"/>
Packit 0f19cf
        </xsl:otherwise>
Packit 0f19cf
      </xsl:choose>
Packit 0f19cf
    </xsl:otherwise>
Packit 0f19cf
  </xsl:choose>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
<xsl:template name="next.itemsymbol">
Packit 0f19cf
  <xsl:param name="itemsymbol" select="'default'"/>
Packit 0f19cf
  <xsl:choose>
Packit 0f19cf
    
Packit 0f19cf
    <xsl:when test="$itemsymbol = 'disc'">circle</xsl:when>
Packit 0f19cf
    <xsl:when test="$itemsymbol = 'circle'">square</xsl:when>
Packit 0f19cf
    <xsl:otherwise>disc</xsl:otherwise>
Packit 0f19cf
  </xsl:choose>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template name="list.itemsymbol">
Packit 0f19cf
  <xsl:param name="node" select="."/>
Packit 0f19cf
Packit 0f19cf
  <xsl:choose>
Packit 0f19cf
    <xsl:when test="@override">
Packit 0f19cf
      <xsl:value-of select="@override"/>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:when test="$node/@mark">
Packit 0f19cf
      <xsl:value-of select="$node/@mark"/>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:otherwise>
Packit 0f19cf
      <xsl:choose>
Packit 0f19cf
        <xsl:when test="$node/ancestor::itemizedlist">
Packit 0f19cf
          <xsl:call-template name="next.itemsymbol">
Packit 0f19cf
            <xsl:with-param name="itemsymbol">
Packit 0f19cf
              <xsl:call-template name="list.itemsymbol">
Packit 0f19cf
                <xsl:with-param name="node" select="$node/ancestor::itemizedlist[1]"/>
Packit 0f19cf
              </xsl:call-template>
Packit 0f19cf
            </xsl:with-param>
Packit 0f19cf
          </xsl:call-template>
Packit 0f19cf
        </xsl:when>
Packit 0f19cf
        <xsl:otherwise>
Packit 0f19cf
          <xsl:call-template name="next.itemsymbol"/>
Packit 0f19cf
        </xsl:otherwise>
Packit 0f19cf
      </xsl:choose>
Packit 0f19cf
    </xsl:otherwise>
Packit 0f19cf
  </xsl:choose>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
<doc:template name="copyright.years" xmlns="">
Packit 0f19cf
<refpurpose>Print a set of years with collapsed ranges</refpurpose>
Packit 0f19cf
Packit 0f19cf
<refdescription id="copyright.years-desc">
Packit 0f19cf
<para>This template prints a list of year elements with consecutive
Packit 0f19cf
years printed as a range. In other words:</para>
Packit 0f19cf
Packit 0f19cf
<screen>1992</year>
Packit 0f19cf
<year>1993</year>
Packit 0f19cf
<year>1994</year>]]></screen>
Packit 0f19cf
Packit 0f19cf
<para>is printed <quote>1992-1994</quote>, whereas:</para>
Packit 0f19cf
Packit 0f19cf
<screen>1992</year>
Packit 0f19cf
<year>1994</year>]]></screen>
Packit 0f19cf
Packit 0f19cf
<para>is printed <quote>1992, 1994</quote>.</para>
Packit 0f19cf
Packit 0f19cf
<para>This template assumes that all the year elements contain only
Packit 0f19cf
decimal year numbers, that the elements are sorted in increasing
Packit 0f19cf
numerical order, that there are no duplicates, and that all the years
Packit 0f19cf
are expressed in full <quote>century+year</quote>
Packit 0f19cf
(<quote>1999</quote> not <quote>99</quote>) notation.</para>
Packit 0f19cf
</refdescription>
Packit 0f19cf
Packit 0f19cf
<refparameter id="copyright.years-params">
Packit 0f19cf
<variablelist>
Packit 0f19cf
<varlistentry><term>years</term>
Packit 0f19cf
<listitem>
Packit 0f19cf
<para>The initial set of year elements.</para>
Packit 0f19cf
</listitem>
Packit 0f19cf
</varlistentry>
Packit 0f19cf
<varlistentry><term>print.ranges</term>
Packit 0f19cf
<listitem>
Packit 0f19cf
<para>If non-zero, multi-year ranges are collapsed. If zero, all years
Packit 0f19cf
are printed discretely.</para>
Packit 0f19cf
</listitem>
Packit 0f19cf
</varlistentry>
Packit 0f19cf
<varlistentry><term>single.year.ranges</term>
Packit 0f19cf
<listitem>
Packit 0f19cf
<para>If non-zero, two consecutive years will be printed as a range,
Packit 0f19cf
otherwise, they will be printed discretely. In other words, a single
Packit 0f19cf
year range is <quote>1991-1992</quote> but discretely it's
Packit 0f19cf
<quote>1991, 1992</quote>.</para>
Packit 0f19cf
</listitem>
Packit 0f19cf
</varlistentry>
Packit 0f19cf
</variablelist>
Packit 0f19cf
</refparameter>
Packit 0f19cf
Packit 0f19cf
<refreturn id="copyright.years-returns">
Packit 0f19cf
<para>This template returns the formatted list of years.</para>
Packit 0f19cf
</refreturn>
Packit 0f19cf
</doc:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template name="copyright.years">
Packit 0f19cf
  <xsl:param name="years"/>
Packit 0f19cf
  <xsl:param name="print.ranges" select="1"/>
Packit 0f19cf
  <xsl:param name="single.year.ranges" select="0"/>
Packit 0f19cf
  <xsl:param name="firstyear" select="0"/>
Packit 0f19cf
  <xsl:param name="nextyear" select="0"/>
Packit 0f19cf
Packit 0f19cf
  
Packit 0f19cf
  <xsl:message terminate="no">
Packit 0f19cf
    <xsl:text>CY: </xsl:text>
Packit 0f19cf
    <xsl:value-of select="count($years)"/>
Packit 0f19cf
    <xsl:text>, </xsl:text>
Packit 0f19cf
    <xsl:value-of select="$firstyear"/>
Packit 0f19cf
    <xsl:text>, </xsl:text>
Packit 0f19cf
    <xsl:value-of select="$nextyear"/>
Packit 0f19cf
    <xsl:text>, </xsl:text>
Packit 0f19cf
    <xsl:value-of select="$print.ranges"/>
Packit 0f19cf
    <xsl:text>, </xsl:text>
Packit 0f19cf
    <xsl:value-of select="$single.year.ranges"/>
Packit 0f19cf
    <xsl:text> (</xsl:text>
Packit 0f19cf
    <xsl:value-of select="$years[1]"/>
Packit 0f19cf
    <xsl:text>)</xsl:text>
Packit 0f19cf
  </xsl:message>
Packit 0f19cf
  -->
Packit 0f19cf
Packit 0f19cf
  <xsl:choose>
Packit 0f19cf
    <xsl:when test="$print.ranges = 0 and count($years) > 0">
Packit 0f19cf
      <xsl:choose>
Packit 0f19cf
        <xsl:when test="count($years) = 1">
Packit 0f19cf
          <xsl:apply-templates select="$years[1]" mode="titlepage.mode"/>
Packit 0f19cf
        </xsl:when>
Packit 0f19cf
        <xsl:otherwise>
Packit 0f19cf
          <xsl:apply-templates select="$years[1]" mode="titlepage.mode"/>
Packit 0f19cf
          <xsl:text>, </xsl:text>
Packit 0f19cf
          <xsl:call-template name="copyright.years">
Packit 0f19cf
            
Packit 0f19cf
                            select="$years[position() > 1]"/>
Packit 0f19cf
            <xsl:with-param name="print.ranges" select="$print.ranges"/>
Packit 0f19cf
            
Packit 0f19cf
                            select="$single.year.ranges"/>
Packit 0f19cf
          </xsl:call-template>
Packit 0f19cf
        </xsl:otherwise>
Packit 0f19cf
      </xsl:choose>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:when test="count($years) = 0">
Packit 0f19cf
      <xsl:variable name="lastyear" select="$nextyear - 1"/>
Packit 0f19cf
      <xsl:choose>
Packit 0f19cf
        <xsl:when test="$firstyear = 0">
Packit 0f19cf
          
Packit 0f19cf
        </xsl:when>
Packit 0f19cf
        <xsl:when test="$firstyear = $lastyear">
Packit 0f19cf
          <xsl:value-of select="$firstyear"/>
Packit 0f19cf
        </xsl:when>
Packit 0f19cf
        
Packit 0f19cf
                        and $lastyear = $firstyear + 1">
Packit 0f19cf
          <xsl:value-of select="$firstyear"/>
Packit 0f19cf
          <xsl:text>, </xsl:text>
Packit 0f19cf
          <xsl:value-of select="$lastyear"/>
Packit 0f19cf
        </xsl:when>
Packit 0f19cf
        <xsl:otherwise>
Packit 0f19cf
          <xsl:value-of select="$firstyear"/>
Packit 0f19cf
          <xsl:text>-</xsl:text>
Packit 0f19cf
          <xsl:value-of select="$lastyear"/>
Packit 0f19cf
        </xsl:otherwise>
Packit 0f19cf
      </xsl:choose>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:when test="$firstyear = 0">
Packit 0f19cf
      <xsl:call-template name="copyright.years">
Packit 0f19cf
        
Packit 0f19cf
                        select="$years[position() > 1]"/>
Packit 0f19cf
        <xsl:with-param name="firstyear" select="$years[1]"/>
Packit 0f19cf
        <xsl:with-param name="nextyear" select="$years[1] + 1"/>
Packit 0f19cf
        <xsl:with-param name="print.ranges" select="$print.ranges"/>
Packit 0f19cf
        
Packit 0f19cf
                        select="$single.year.ranges"/>
Packit 0f19cf
      </xsl:call-template>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:when test="$nextyear = $years[1]">
Packit 0f19cf
      <xsl:call-template name="copyright.years">
Packit 0f19cf
        
Packit 0f19cf
                        select="$years[position() > 1]"/>
Packit 0f19cf
        <xsl:with-param name="firstyear" select="$firstyear"/>
Packit 0f19cf
        <xsl:with-param name="nextyear" select="$nextyear + 1"/>
Packit 0f19cf
        <xsl:with-param name="print.ranges" select="$print.ranges"/>
Packit 0f19cf
        
Packit 0f19cf
                        select="$single.year.ranges"/>
Packit 0f19cf
      </xsl:call-template>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:otherwise>
Packit 0f19cf
      
Packit 0f19cf
      <xsl:choose>
Packit 0f19cf
        <xsl:when test="$nextyear = $firstyear + 1">
Packit 0f19cf
          <xsl:value-of select="$firstyear"/>
Packit 0f19cf
          <xsl:text>, </xsl:text>
Packit 0f19cf
        </xsl:when>
Packit 0f19cf
        
Packit 0f19cf
                        and $nextyear = $firstyear + 2">
Packit 0f19cf
          <xsl:value-of select="$firstyear"/>
Packit 0f19cf
          <xsl:text>, </xsl:text>
Packit 0f19cf
          <xsl:value-of select="$nextyear - 1"/>
Packit 0f19cf
          <xsl:text>, </xsl:text>
Packit 0f19cf
        </xsl:when>
Packit 0f19cf
        <xsl:otherwise>
Packit 0f19cf
          <xsl:value-of select="$firstyear"/>
Packit 0f19cf
          <xsl:text>-</xsl:text>
Packit 0f19cf
          <xsl:value-of select="$nextyear - 1"/>
Packit 0f19cf
          <xsl:text>, </xsl:text>
Packit 0f19cf
        </xsl:otherwise>
Packit 0f19cf
      </xsl:choose>
Packit 0f19cf
      <xsl:call-template name="copyright.years">
Packit 0f19cf
        
Packit 0f19cf
                        select="$years[position() > 1]"/>
Packit 0f19cf
        <xsl:with-param name="firstyear" select="$years[1]"/>
Packit 0f19cf
        <xsl:with-param name="nextyear" select="$years[1] + 1"/>
Packit 0f19cf
        <xsl:with-param name="print.ranges" select="$print.ranges"/>
Packit 0f19cf
        
Packit 0f19cf
                        select="$single.year.ranges"/>
Packit 0f19cf
      </xsl:call-template>
Packit 0f19cf
    </xsl:otherwise>
Packit 0f19cf
  </xsl:choose>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
<doc:template name="find.path.params" xmlns="">
Packit 0f19cf
<refpurpose>Search in a table for the "best" match for the node</refpurpose>
Packit 0f19cf
Packit 0f19cf
<refdescription id="find.path.params-desc">
Packit 0f19cf
<para>This template searches in a table for the value that most-closely
Packit 0f19cf
(in the typical best-match sense of XSLT) matches the current (element)
Packit 0f19cf
node location.</para>
Packit 0f19cf
</refdescription>
Packit 0f19cf
</doc:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template name="find.path.params">
Packit 0f19cf
  <xsl:param name="node" select="."/>
Packit 0f19cf
  <xsl:param name="table" select="''"/>
Packit 0f19cf
  <xsl:param name="location">
Packit 0f19cf
    <xsl:call-template name="xpath.location">
Packit 0f19cf
      <xsl:with-param name="node" select="$node"/>
Packit 0f19cf
    </xsl:call-template>
Packit 0f19cf
  </xsl:param>
Packit 0f19cf
Packit 0f19cf
  <xsl:variable name="value">
Packit 0f19cf
    <xsl:call-template name="lookup.key">
Packit 0f19cf
      <xsl:with-param name="key" select="$location"/>
Packit 0f19cf
      <xsl:with-param name="table" select="$table"/>
Packit 0f19cf
    </xsl:call-template>
Packit 0f19cf
  </xsl:variable>
Packit 0f19cf
Packit 0f19cf
  <xsl:choose>
Packit 0f19cf
    <xsl:when test="$value != ''">
Packit 0f19cf
      <xsl:value-of select="$value"/>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:when test="contains($location, '/')">
Packit 0f19cf
      <xsl:call-template name="find.path.params">
Packit 0f19cf
        <xsl:with-param name="node" select="$node"/>
Packit 0f19cf
        <xsl:with-param name="table" select="$table"/>
Packit 0f19cf
        <xsl:with-param name="location" select="substring-after($location, '/')"/>
Packit 0f19cf
      </xsl:call-template>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
  </xsl:choose>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
<xsl:template name="relative-uri">
Packit 0f19cf
  <xsl:param name="filename" select="."/>
Packit 0f19cf
  <xsl:param name="destdir" select="''"/>
Packit 0f19cf
  
Packit 0f19cf
  <xsl:variable name="srcurl">
Packit 0f19cf
    <xsl:call-template name="strippath">
Packit 0f19cf
      <xsl:with-param name="filename">
Packit 0f19cf
        <xsl:call-template name="xml.base.dirs">
Packit 0f19cf
          
Packit 0f19cf
                          select="$filename/ancestor-or-self::*
Packit 0f19cf
                                   [@xml:base != ''][1]"/>
Packit 0f19cf
        </xsl:call-template>
Packit 0f19cf
        <xsl:value-of select="$filename"/>
Packit 0f19cf
      </xsl:with-param>
Packit 0f19cf
    </xsl:call-template>
Packit 0f19cf
  </xsl:variable>
Packit 0f19cf
Packit 0f19cf
  <xsl:variable name="srcurl.trimmed">
Packit 0f19cf
    <xsl:call-template name="trim.common.uri.paths">
Packit 0f19cf
      <xsl:with-param name="uriA" select="$srcurl"/>
Packit 0f19cf
      <xsl:with-param name="uriB" select="$destdir"/>
Packit 0f19cf
      <xsl:with-param name="return" select="'A'"/>
Packit 0f19cf
    </xsl:call-template>
Packit 0f19cf
  </xsl:variable>
Packit 0f19cf
Packit 0f19cf
  <xsl:variable name="destdir.trimmed">
Packit 0f19cf
    <xsl:call-template name="trim.common.uri.paths">
Packit 0f19cf
      <xsl:with-param name="uriA" select="$srcurl"/>
Packit 0f19cf
      <xsl:with-param name="uriB" select="$destdir"/>
Packit 0f19cf
      <xsl:with-param name="return" select="'B'"/>
Packit 0f19cf
    </xsl:call-template>
Packit 0f19cf
  </xsl:variable>
Packit 0f19cf
Packit 0f19cf
  <xsl:variable name="depth">
Packit 0f19cf
    <xsl:call-template name="count.uri.path.depth">
Packit 0f19cf
      <xsl:with-param name="filename" select="$destdir.trimmed"/>
Packit 0f19cf
    </xsl:call-template>
Packit 0f19cf
  </xsl:variable>
Packit 0f19cf
Packit 0f19cf
  <xsl:call-template name="copy-string">
Packit 0f19cf
    <xsl:with-param name="string" select="'../'"/>
Packit 0f19cf
    <xsl:with-param name="count" select="$depth"/>
Packit 0f19cf
  </xsl:call-template>
Packit 0f19cf
  <xsl:value-of select="$srcurl.trimmed"/>
Packit 0f19cf
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
<xsl:template name="xml.base.dirs">
Packit 0f19cf
  <xsl:param name="base.elem" select="NONODE"/>
Packit 0f19cf
Packit 0f19cf
  
Packit 0f19cf
       full path with : in uri -->
Packit 0f19cf
  
Packit 0f19cf
                not(contains($base.elem/@xml:base, ':'))">
Packit 0f19cf
    <xsl:call-template name="xml.base.dirs">
Packit 0f19cf
      
Packit 0f19cf
                      select="$base.elem/ancestor::*[@xml:base != ''][1]"/>
Packit 0f19cf
    </xsl:call-template>
Packit 0f19cf
  </xsl:if>
Packit 0f19cf
  <xsl:call-template name="getdir">
Packit 0f19cf
    <xsl:with-param name="filename" select="$base.elem/@xml:base"/>
Packit 0f19cf
  </xsl:call-template>
Packit 0f19cf
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
<xsl:template name="strippath">
Packit 0f19cf
  <xsl:param name="filename" select="''"/>
Packit 0f19cf
  <xsl:choose>
Packit 0f19cf
    
Packit 0f19cf
    <xsl:when test="starts-with($filename, '../')">
Packit 0f19cf
      <xsl:value-of select="'../'"/>
Packit 0f19cf
      <xsl:call-template name="strippath">
Packit 0f19cf
        <xsl:with-param name="filename" select="substring-after($filename, '../')"/>
Packit 0f19cf
      </xsl:call-template>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:when test="contains($filename, '/../')">
Packit 0f19cf
      <xsl:call-template name="strippath">
Packit 0f19cf
        <xsl:with-param name="filename">
Packit 0f19cf
          <xsl:call-template name="getdir">
Packit 0f19cf
            <xsl:with-param name="filename" select="substring-before($filename, '/../')"/>
Packit 0f19cf
          </xsl:call-template>
Packit 0f19cf
          <xsl:value-of select="substring-after($filename, '/../')"/>
Packit 0f19cf
        </xsl:with-param>
Packit 0f19cf
      </xsl:call-template>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    <xsl:otherwise>
Packit 0f19cf
      <xsl:value-of select="$filename"/>
Packit 0f19cf
    </xsl:otherwise>
Packit 0f19cf
  </xsl:choose>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
<xsl:template name="getdir">
Packit 0f19cf
  <xsl:param name="filename" select="''"/>
Packit 0f19cf
  <xsl:if test="contains($filename, '/')">
Packit 0f19cf
    <xsl:value-of select="substring-before($filename, '/')"/>
Packit 0f19cf
    <xsl:text>/</xsl:text>
Packit 0f19cf
    <xsl:call-template name="getdir">
Packit 0f19cf
      <xsl:with-param name="filename" select="substring-after($filename, '/')"/>
Packit 0f19cf
    </xsl:call-template>
Packit 0f19cf
  </xsl:if>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
<doc:template name="string.upper" xmlns="">
Packit 0f19cf
<refpurpose>Converts a string to all uppercase letters</refpurpose>
Packit 0f19cf
Packit 0f19cf
<refdescription id="string.upper-desc">
Packit 0f19cf
<para>Given a string, this template does a language-aware conversion
Packit 0f19cf
of that string to all uppercase letters, based on the values of the
Packit 0f19cf
<literal>lowercase.alpha</literal> and
Packit 0f19cf
<literal>uppercase.alpha</literal> gentext keys for the current
Packit 0f19cf
locale. It affects only those characters found in the values of
Packit 0f19cf
<literal>lowercase.alpha</literal> and
Packit 0f19cf
<literal>uppercase.alpha</literal>. All other characters are left
Packit 0f19cf
unchanged.</para>
Packit 0f19cf
</refdescription>
Packit 0f19cf
Packit 0f19cf
<refparameter id="string.upper-params">
Packit 0f19cf
<variablelist>
Packit 0f19cf
<varlistentry><term>string</term>
Packit 0f19cf
<listitem>
Packit 0f19cf
<para>The string to convert to uppercase.</para>
Packit 0f19cf
</listitem>
Packit 0f19cf
</varlistentry>
Packit 0f19cf
</variablelist>
Packit 0f19cf
</refparameter>
Packit 0f19cf
</doc:template>
Packit 0f19cf
<xsl:template name="string.upper">
Packit 0f19cf
  <xsl:param name="string" select="''"/>
Packit 0f19cf
  <xsl:variable name="lowercase.alpha">
Packit 0f19cf
    <xsl:call-template name="gentext">
Packit 0f19cf
      <xsl:with-param name="key" select="'lowercase.alpha'"/>
Packit 0f19cf
    </xsl:call-template>
Packit 0f19cf
  </xsl:variable>
Packit 0f19cf
  <xsl:variable name="uppercase.alpha">
Packit 0f19cf
    <xsl:call-template name="gentext">
Packit 0f19cf
      <xsl:with-param name="key" select="'uppercase.alpha'"/>
Packit 0f19cf
    </xsl:call-template>
Packit 0f19cf
  </xsl:variable>
Packit 0f19cf
  <xsl:value-of select="translate($string,$lowercase.alpha,$uppercase.alpha)"/>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
<doc:template name="string.lower" xmlns="">
Packit 0f19cf
<refpurpose>Converts a string to all lowercase letters</refpurpose>
Packit 0f19cf
Packit 0f19cf
<refdescription id="string.lower-desc">
Packit 0f19cf
<para>Given a string, this template does a language-aware conversion
Packit 0f19cf
of that string to all lowercase letters, based on the values of the
Packit 0f19cf
<literal>uppercase.alpha</literal> and
Packit 0f19cf
<literal>lowercase.alpha</literal> gentext keys for the current
Packit 0f19cf
locale. It affects only those characters found in the values of
Packit 0f19cf
<literal>uppercase.alpha</literal> and
Packit 0f19cf
<literal>lowercase.alpha</literal>. All other characters are left
Packit 0f19cf
unchanged.</para>
Packit 0f19cf
</refdescription>
Packit 0f19cf
Packit 0f19cf
<refparameter id="string.lower-params">
Packit 0f19cf
<variablelist>
Packit 0f19cf
<varlistentry><term>string</term>
Packit 0f19cf
<listitem>
Packit 0f19cf
<para>The string to convert to lowercase.</para>
Packit 0f19cf
</listitem>
Packit 0f19cf
</varlistentry>
Packit 0f19cf
</variablelist>
Packit 0f19cf
</refparameter>
Packit 0f19cf
</doc:template>
Packit 0f19cf
<xsl:template name="string.lower">
Packit 0f19cf
  <xsl:param name="string" select="''"/>
Packit 0f19cf
  <xsl:variable name="uppercase.alpha">
Packit 0f19cf
    <xsl:call-template name="gentext">
Packit 0f19cf
      <xsl:with-param name="key" select="'uppercase.alpha'"/>
Packit 0f19cf
    </xsl:call-template>
Packit 0f19cf
  </xsl:variable>
Packit 0f19cf
  <xsl:variable name="lowercase.alpha">
Packit 0f19cf
    <xsl:call-template name="gentext">
Packit 0f19cf
      <xsl:with-param name="key" select="'lowercase.alpha'"/>
Packit 0f19cf
    </xsl:call-template>
Packit 0f19cf
  </xsl:variable>
Packit 0f19cf
  <xsl:value-of select="translate($string,$uppercase.alpha,$lowercase.alpha)"/>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
<doc:template name="select.choice.separator" xmlns="">
Packit 0f19cf
  <refpurpose>Returns localized choice separator</refpurpose>
Packit 0f19cf
  <refdescription id="select.choice.separator-desc">
Packit 0f19cf
    <para>This template enables auto-generation of an appropriate
Packit 0f19cf
    localized "choice" separator (for example, "and" or "or") before
Packit 0f19cf
    the final item in an inline list (though it could also be useful
Packit 0f19cf
    for generating choice separators for non-inline lists).</para>
Packit 0f19cf
    <para>It currently works by evaluating a processing instruction
Packit 0f19cf
    (PI) of the form <?dbchoice choice="foo"?> :
Packit 0f19cf
    <itemizedlist>
Packit 0f19cf
      <listitem>
Packit 0f19cf
        <simpara>if the value of the <tag>choice</tag>
Packit 0f19cf
        pseudo-attribute is "and" or "or", returns a localized "and"
Packit 0f19cf
        or "or"</simpara>
Packit 0f19cf
      </listitem>
Packit 0f19cf
      <listitem>
Packit 0f19cf
        <simpara>otherwise returns the literal value of the
Packit 0f19cf
        <tag>choice</tag> pseudo-attribute</simpara>
Packit 0f19cf
      </listitem>
Packit 0f19cf
    </itemizedlist>
Packit 0f19cf
    The latter is provided only as a temporary workaround because the
Packit 0f19cf
    locale files do not currently have translations for the word
Packit 0f19cf
    <wordasword>or</wordasword>. So if you want to generate a a
Packit 0f19cf
    logical "or" separator in French (for example), you currently need
Packit 0f19cf
    to do this:
Packit 0f19cf
    <literallayout><?dbchoice choice="ou"?></literallayout>
Packit 0f19cf
    </para>
Packit 0f19cf
    <warning>
Packit 0f19cf
      <para>The <tag>dbchoice</tag> processing instruction is
Packit 0f19cf
      an unfortunate hack; support for it may disappear in the future
Packit 0f19cf
      (particularly if and when a more appropriate means for marking
Packit 0f19cf
      up "choice" lists becomes available in DocBook).</para>
Packit 0f19cf
    </warning>
Packit 0f19cf
  </refdescription>
Packit 0f19cf
</doc:template>
Packit 0f19cf
<xsl:template name="select.choice.separator">
Packit 0f19cf
  <xsl:variable name="choice">
Packit 0f19cf
    <xsl:call-template name="pi.dbchoice_choice"/>
Packit 0f19cf
  </xsl:variable>
Packit 0f19cf
  <xsl:choose>
Packit 0f19cf
    
Packit 0f19cf
    
Packit 0f19cf
    <xsl:when test="$choice = 'and' or $choice = 'or'">
Packit 0f19cf
      <xsl:call-template name="gentext">
Packit 0f19cf
        <xsl:with-param name="key" select="$choice"/>
Packit 0f19cf
      </xsl:call-template>
Packit 0f19cf
    </xsl:when>
Packit 0f19cf
    
Packit 0f19cf
    <xsl:otherwise>
Packit 0f19cf
      <xsl:value-of select="$choice"/>
Packit 0f19cf
    </xsl:otherwise>
Packit 0f19cf
  </xsl:choose>
Packit 0f19cf
</xsl:template>
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
Packit 0f19cf
<doc:template name="evaluate.info.profile" xmlns="">
Packit 0f19cf
  <refpurpose>Evaluates an info profile</refpurpose>
Packit 0f19cf
  <refdescription id="evaluate.info.profile-desc">
Packit 0f19cf
    <para>This template evaluates an "info profile" matching the XPath
Packit 0f19cf
    expression given by the <parameter>profile</parameter>
Packit 0f19cf
    parameter. It relies on the XSLT <function>evaluate()</function>
Packit 0f19cf
    extension function.</para>
Packit 0f19cf
Packit 0f19cf
    <para>The value of the <parameter>profile</parameter> parameter
Packit 0f19cf
    can include the literal string <literal>$info</literal>. If found
Packit 0f19cf
    in the value of the <parameter>profile</parameter> parameter, the
Packit 0f19cf
    literal string <literal>$info</literal> string is replaced with
Packit 0f19cf
    the value of the <parameter>info</parameter> parameter, which
Packit 0f19cf
    should be a set of <replaceable>*info</replaceable> nodes; the
Packit 0f19cf
    expression is then evaluated using the XSLT
Packit 0f19cf
    <function>evaluate()</function> extension function.</para>
Packit 0f19cf
  </refdescription>
Packit 0f19cf
  <refparameter id="evaluate.info.profile-params">
Packit 0f19cf
    <variablelist>
Packit 0f19cf
       <varlistentry>
Packit 0f19cf
        <term>profile</term>
Packit 0f19cf
        <listitem>
Packit 0f19cf
          <para>A string representing an XPath expression </para>
Packit 0f19cf
        </listitem>
Packit 0f19cf
      </varlistentry>
Packit 0f19cf
       <varlistentry>
Packit 0f19cf
        <term>info</term>
Packit 0f19cf
        <listitem>
Packit 0f19cf
          <para>A set of *info nodes</para>
Packit 0f19cf
        </listitem>
Packit 0f19cf
      </varlistentry>
Packit 0f19cf
    </variablelist>
Packit 0f19cf
  </refparameter>
Packit 0f19cf
Packit 0f19cf
  <refreturn id="evaluate.info.profile-returns">
Packit 0f19cf
    <para>Returns a node (the result of evaluating the
Packit 0f19cf
    <parameter>profile</parameter> parameter)</para>
Packit 0f19cf
  </refreturn>
Packit 0f19cf
</doc:template>
Packit 0f19cf
  <xsl:template name="evaluate.info.profile">
Packit 0f19cf
    <xsl:param name="profile"/>
Packit 0f19cf
    <xsl:param name="info"/>
Packit 0f19cf
    <xsl:choose>
Packit 0f19cf
      
Packit 0f19cf
      <xsl:when test="function-available('dyn:evaluate')">
Packit 0f19cf
        
Packit 0f19cf
            select="dyn:evaluate($profile)" mode="get.refentry.metadata"/>
Packit 0f19cf
      </xsl:when>
Packit 0f19cf
      
Packit 0f19cf
      <xsl:when test="function-available('saxon:evaluate')">
Packit 0f19cf
        
Packit 0f19cf
            select="saxon:evaluate($profile)" mode="get.refentry.metadata"/>
Packit 0f19cf
      </xsl:when>
Packit 0f19cf
      <xsl:otherwise>
Packit 0f19cf
        <xsl:message terminate="yes">
Packit 0f19cf
Error: The "info profiling" mechanism currently requires an XSLT
Packit 0f19cf
engine that supports the evaluate() XSLT extension function. Your XSLT
Packit 0f19cf
engine does not support it.
Packit 0f19cf
</xsl:message>
Packit 0f19cf
      </xsl:otherwise>
Packit 0f19cf
    </xsl:choose>
Packit 0f19cf
  </xsl:template>
Packit 0f19cf
</xsl:stylesheet>