+<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
xmlns:cf="http://docbook.sourceforge.net/xmlns/chunkfast/1.0"
xmlns:ng="http://docbook.org/docbook-ng"
xmlns:db="http://docbook.org/ns/docbook"
- version="1.0"
- exclude-result-prefixes="exsl cf ng db">
+ exclude-result-prefixes="exsl cf ng db"
+ version="1.0">
<!-- ********************************************************************
$Id$
<!-- ==================================================================== -->
-<xsl:param name="onechunk" select="0"/>
-<xsl:param name="refentry.separator" select="0"/>
-<xsl:param name="chunk.fast" select="0"/>
-<xsl:key name="genid" match="*" use="generate-id()"/>
+<xsl:template match="*" mode="chunk-filename">
+ <!-- returns the filename of a chunk -->
+ <xsl:variable name="ischunk">
+ <xsl:call-template name="chunk"/>
+ </xsl:variable>
-<!-- ==================================================================== -->
+ <xsl:variable name="fn">
+ <xsl:apply-templates select="." mode="recursive-chunk-filename"/>
+ </xsl:variable>
-<xsl:variable name="chunk.hierarchy">
- <xsl:if test="$chunk.fast != 0">
- <xsl:choose>
- <xsl:when test="function-available('exsl:node-set')">
- <xsl:message>Computing chunks...</xsl:message>
- <xsl:apply-templates select="/*" mode="find.chunks"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:message>
- <xsl:text>Fast chunking requires exsl:node-set(). </xsl:text>
- <xsl:text>Using "slow" chunking.</xsl:text>
- </xsl:message>
- </xsl:otherwise>
- </xsl:choose>
+ <!--
+ <xsl:message>
+ <xsl:value-of select="$ischunk"/>
+ <xsl:text> (</xsl:text>
+ <xsl:value-of select="local-name(.)"/>
+ <xsl:text>) </xsl:text>
+ <xsl:value-of select="$fn"/>
+ <xsl:text>, </xsl:text>
+ <xsl:call-template name="dbhtml-dir"/>
+ </xsl:message>
+ -->
+
+ <!-- 2003-11-25 by ndw:
+ The following test used to read test="$ischunk != 0 and $fn != ''"
+ I've removed the ischunk part of the test so that href.to.uri and
+ href.from.uri will be fully qualified even if the source or target
+ isn't a chunk. I *think* that if $fn != '' then it's appropriate
+ to put the directory on the front, even if the element isn't a
+ chunk. I could be wrong. -->
+
+ <xsl:if test="$fn != ''">
+ <xsl:call-template name="dbhtml-dir"/>
</xsl:if>
-</xsl:variable>
-<xsl:template match="*" mode="find.chunks">
- <xsl:variable name="chunk">
+ <xsl:value-of select="$fn"/>
+ <!-- You can't add the html.ext here because dbhtml filename= may already -->
+ <!-- have added it. It really does have to be handled in the recursive template -->
+</xsl:template>
+
+<xsl:template match="*" mode="recursive-chunk-filename">
+ <xsl:param name="recursive" select="false()"/>
+
+ <!-- returns the filename of a chunk -->
+ <xsl:variable name="ischunk">
<xsl:call-template name="chunk"/>
</xsl:variable>
+ <xsl:variable name="dbhtml-filename">
+ <xsl:call-template name="dbhtml-filename"/>
+ </xsl:variable>
+
+ <xsl:variable name="filename">
+ <xsl:choose>
+ <xsl:when test="$dbhtml-filename != ''">
+ <xsl:value-of select="$dbhtml-filename"/>
+ </xsl:when>
+ <!-- if this is the root element, use the root.filename -->
+ <xsl:when test="not(parent::*) and $root.filename != ''">
+ <xsl:value-of select="$root.filename"/>
+ <xsl:value-of select="$html.ext"/>
+ </xsl:when>
+ <!-- Special case -->
+ <xsl:when test="self::legalnotice and $generate.legalnotice.link != 0">
+ <xsl:variable name="id">
+ <xsl:call-template name="object.id"/>
+ </xsl:variable>
+ <xsl:value-of select="concat('ln-',$id,$html.ext)"/>
+ </xsl:when>
+ <!-- if there's no dbhtml filename, and if we're to use IDs as -->
+ <!-- filenames, then use the ID to generate the filename. -->
+ <xsl:when test="(@id or @xml:id) and $use.id.as.filename != 0">
+ <xsl:value-of select="(@id|@xml:id)[1]"/>
+ <xsl:value-of select="$html.ext"/>
+ </xsl:when>
+ <xsl:otherwise></xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
<xsl:choose>
- <xsl:when test="$chunk != 0">
- <cf:div id="{generate-id()}">
- <xsl:apply-templates select="." mode="class.attribute"/>
- <xsl:apply-templates select="*" mode="find.chunks"/>
- </cf:div>
+ <xsl:when test="$ischunk='0'">
+ <!-- if called on something that isn't a chunk, walk up... -->
+ <xsl:choose>
+ <xsl:when test="count(parent::*)>0">
+ <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
+ <xsl:with-param name="recursive" select="$recursive"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <!-- unless there is no up, in which case return "" -->
+ <xsl:otherwise></xsl:otherwise>
+ </xsl:choose>
</xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates select="*" mode="find.chunks"/>
- </xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-<!-- ==================================================================== -->
+ <xsl:when test="not($recursive) and $filename != ''">
+ <!-- if this chunk has an explicit name, use it -->
+ <xsl:value-of select="$filename"/>
+ </xsl:when>
-<xsl:template name="process-chunk-element">
- <xsl:param name="content">
- <xsl:apply-imports/>
- </xsl:param>
+ <xsl:when test="self::set">
+ <xsl:value-of select="$root.filename"/>
+ <xsl:if test="not($recursive)">
+ <xsl:value-of select="$html.ext"/>
+ </xsl:if>
+ </xsl:when>
- <xsl:choose>
- <xsl:when test="$chunk.fast != 0 and function-available('exsl:node-set')">
- <xsl:variable name="chunks" select="exsl:node-set($chunk.hierarchy)//cf:div"/>
- <xsl:variable name="genid" select="generate-id()"/>
+ <xsl:when test="self::book">
+ <xsl:text>bk</xsl:text>
+ <xsl:number level="any" format="01"/>
+ <xsl:if test="not($recursive)">
+ <xsl:value-of select="$html.ext"/>
+ </xsl:if>
+ </xsl:when>
- <xsl:variable name="div" select="$chunks[@id=$genid or @xml:id=$genid]"/>
+ <xsl:when test="self::article">
+ <xsl:if test="/set">
+ <!-- in a set, make sure we inherit the right book info... -->
+ <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
+ <xsl:with-param name="recursive" select="true()"/>
+ </xsl:apply-templates>
+ </xsl:if>
+
+ <xsl:text>ar</xsl:text>
+ <xsl:number level="any" format="01" from="book"/>
+ <xsl:if test="not($recursive)">
+ <xsl:value-of select="$html.ext"/>
+ </xsl:if>
+ </xsl:when>
- <xsl:variable name="prevdiv"
- select="($div/preceding-sibling::cf:div|$div/preceding::cf:div|$div/parent::cf:div)[last()]"/>
- <xsl:variable name="prev" select="key('genid', ($prevdiv/@id|$prevdiv/@xml:id)[1])"/>
+ <xsl:when test="self::preface">
+ <xsl:if test="/set">
+ <!-- in a set, make sure we inherit the right book info... -->
+ <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
+ <xsl:with-param name="recursive" select="true()"/>
+ </xsl:apply-templates>
+ </xsl:if>
+
+ <xsl:text>pr</xsl:text>
+ <xsl:number level="any" format="01" from="book"/>
+ <xsl:if test="not($recursive)">
+ <xsl:value-of select="$html.ext"/>
+ </xsl:if>
+ </xsl:when>
- <xsl:variable name="nextdiv"
- select="($div/following-sibling::cf:div|$div/following::cf:div|$div/cf:div)[1]"/>
- <xsl:variable name="next" select="key('genid', ($nextdiv/@id|$nextdiv/@xml:id)[1])"/>
+ <xsl:when test="self::chapter">
+ <xsl:if test="/set">
+ <!-- in a set, make sure we inherit the right book info... -->
+ <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
+ <xsl:with-param name="recursive" select="true()"/>
+ </xsl:apply-templates>
+ </xsl:if>
+
+ <xsl:text>ch</xsl:text>
+ <xsl:number level="any" format="01" from="book"/>
+ <xsl:if test="not($recursive)">
+ <xsl:value-of select="$html.ext"/>
+ </xsl:if>
+ </xsl:when>
+ <xsl:when test="self::appendix">
+ <xsl:if test="/set">
+ <!-- in a set, make sure we inherit the right book info... -->
+ <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
+ <xsl:with-param name="recursive" select="true()"/>
+ </xsl:apply-templates>
+ </xsl:if>
+
+ <xsl:text>ap</xsl:text>
+ <xsl:number level="any" format="a" from="book"/>
+ <xsl:if test="not($recursive)">
+ <xsl:value-of select="$html.ext"/>
+ </xsl:if>
+ </xsl:when>
+
+ <xsl:when test="self::part">
<xsl:choose>
- <xsl:when test="$onechunk != 0 and parent::*">
- <xsl:copy-of select="$content"/>
+ <xsl:when test="/set">
+ <!-- in a set, make sure we inherit the right book info... -->
+ <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
+ <xsl:with-param name="recursive" select="true()"/>
+ </xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
- <xsl:call-template name="process-chunk">
- <xsl:with-param name="prev" select="$prev"/>
- <xsl:with-param name="next" select="$next"/>
- <xsl:with-param name="content" select="$content"/>
- </xsl:call-template>
</xsl:otherwise>
</xsl:choose>
+
+ <xsl:text>pt</xsl:text>
+ <xsl:number level="any" format="01" from="book"/>
+ <xsl:if test="not($recursive)">
+ <xsl:value-of select="$html.ext"/>
+ </xsl:if>
</xsl:when>
- <xsl:otherwise>
+
+ <xsl:when test="self::reference">
<xsl:choose>
- <xsl:when test="$onechunk != 0 and not(parent::*)">
- <xsl:call-template name="chunk-all-sections">
- <xsl:with-param name="content" select="$content"/>
- </xsl:call-template>
+ <xsl:when test="/set">
+ <!-- in a set, make sure we inherit the right book info... -->
+ <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
+ <xsl:with-param name="recursive" select="true()"/>
+ </xsl:apply-templates>
</xsl:when>
- <xsl:when test="$onechunk != 0">
- <xsl:copy-of select="$content"/>
+ <xsl:otherwise>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:text>rn</xsl:text>
+ <xsl:number level="any" format="01" from="book"/>
+ <xsl:if test="not($recursive)">
+ <xsl:value-of select="$html.ext"/>
+ </xsl:if>
+ </xsl:when>
+
+ <xsl:when test="self::refentry">
+ <xsl:choose>
+ <xsl:when test="parent::reference">
+ <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
+ <xsl:with-param name="recursive" select="true()"/>
+ </xsl:apply-templates>
</xsl:when>
- <xsl:when test="$chunk.first.sections = 0">
- <xsl:call-template name="chunk-first-section-with-parent">
- <xsl:with-param name="content" select="$content"/>
- </xsl:call-template>
+ <xsl:otherwise>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:text>re</xsl:text>
+ <xsl:number level="any" format="01" from="book"/>
+ <xsl:if test="not($recursive)">
+ <xsl:value-of select="$html.ext"/>
+ </xsl:if>
+ </xsl:when>
+
+ <xsl:when test="self::colophon">
+ <xsl:choose>
+ <xsl:when test="/set">
+ <!-- in a set, make sure we inherit the right book info... -->
+ <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
+ <xsl:with-param name="recursive" select="true()"/>
+ </xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
- <xsl:call-template name="chunk-all-sections">
- <xsl:with-param name="content" select="$content"/>
- </xsl:call-template>
</xsl:otherwise>
</xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-<xsl:template name="process-chunk">
- <xsl:param name="prev" select="."/>
- <xsl:param name="next" select="."/>
- <xsl:param name="content">
- <xsl:apply-imports/>
- </xsl:param>
+ <xsl:text>co</xsl:text>
+ <xsl:number level="any" format="01" from="book"/>
+ <xsl:if test="not($recursive)">
+ <xsl:value-of select="$html.ext"/>
+ </xsl:if>
+ </xsl:when>
- <xsl:variable name="ischunk">
- <xsl:call-template name="chunk"/>
- </xsl:variable>
+ <xsl:when test="self::sect1
+ or self::sect2
+ or self::sect3
+ or self::sect4
+ or self::sect5
+ or self::section">
+ <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
+ <xsl:with-param name="recursive" select="true()"/>
+ </xsl:apply-templates>
+ <xsl:text>s</xsl:text>
+ <xsl:number format="01"/>
+ <xsl:if test="not($recursive)">
+ <xsl:value-of select="$html.ext"/>
+ </xsl:if>
+ </xsl:when>
- <xsl:variable name="chunkfn">
- <xsl:if test="$ischunk='1'">
- <xsl:apply-templates mode="chunk-filename" select="."/>
- </xsl:if>
- </xsl:variable>
+ <xsl:when test="self::bibliography">
+ <xsl:choose>
+ <xsl:when test="/set">
+ <!-- in a set, make sure we inherit the right book info... -->
+ <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
+ <xsl:with-param name="recursive" select="true()"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ </xsl:otherwise>
+ </xsl:choose>
- <xsl:if test="$ischunk='0'">
- <xsl:message>
- <xsl:text>Error </xsl:text>
- <xsl:value-of select="name(.)"/>
- <xsl:text> is not a chunk!</xsl:text>
- </xsl:message>
- </xsl:if>
+ <xsl:text>bi</xsl:text>
+ <xsl:number level="any" format="01" from="book"/>
+ <xsl:if test="not($recursive)">
+ <xsl:value-of select="$html.ext"/>
+ </xsl:if>
+ </xsl:when>
- <xsl:variable name="filename">
- <xsl:call-template name="make-relative-filename">
- <xsl:with-param name="base.dir" select="$base.dir"/>
- <xsl:with-param name="base.name" select="$chunkfn"/>
- </xsl:call-template>
- </xsl:variable>
+ <xsl:when test="self::glossary">
+ <xsl:choose>
+ <xsl:when test="/set">
+ <!-- in a set, make sure we inherit the right book info... -->
+ <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
+ <xsl:with-param name="recursive" select="true()"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ </xsl:otherwise>
+ </xsl:choose>
- <xsl:call-template name="write.chunk">
- <xsl:with-param name="filename" select="$filename"/>
- <xsl:with-param name="content">
- <xsl:call-template name="chunk-element-content">
- <xsl:with-param name="prev" select="$prev"/>
- <xsl:with-param name="next" select="$next"/>
- <xsl:with-param name="content" select="$content"/>
- </xsl:call-template>
- </xsl:with-param>
- <xsl:with-param name="quiet" select="$chunk.quietly"/>
- </xsl:call-template>
-</xsl:template>
+ <xsl:text>go</xsl:text>
+ <xsl:number level="any" format="01" from="book"/>
+ <xsl:if test="not($recursive)">
+ <xsl:value-of select="$html.ext"/>
+ </xsl:if>
+ </xsl:when>
+
+ <xsl:when test="self::index">
+ <xsl:choose>
+ <xsl:when test="/set">
+ <!-- in a set, make sure we inherit the right book info... -->
+ <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
+ <xsl:with-param name="recursive" select="true()"/>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ </xsl:otherwise>
+ </xsl:choose>
-<xsl:template name="chunk-first-section-with-parent">
- <xsl:param name="content">
- <xsl:apply-imports/>
- </xsl:param>
-
- <!-- These xpath expressions are really hairy. The trick is to pick sections -->
- <!-- that are not first children and are not the children of first children -->
-
- <!-- Break these variables into pieces to work around
- http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6063 -->
-
- <xsl:variable name="prev-v1"
- select="(ancestor::sect1[$chunk.section.depth > 0
- and preceding-sibling::sect1][1]
-
- |ancestor::sect2[$chunk.section.depth > 1
- and preceding-sibling::sect2
- and parent::sect1[preceding-sibling::sect1]][1]
-
- |ancestor::sect3[$chunk.section.depth > 2
- and preceding-sibling::sect3
- and parent::sect2[preceding-sibling::sect2]
- and ancestor::sect1[preceding-sibling::sect1]][1]
-
- |ancestor::sect4[$chunk.section.depth > 3
- and preceding-sibling::sect4
- and parent::sect3[preceding-sibling::sect3]
- and ancestor::sect2[preceding-sibling::sect2]
- and ancestor::sect1[preceding-sibling::sect1]][1]
-
- |ancestor::sect5[$chunk.section.depth > 4
- and preceding-sibling::sect5
- and parent::sect4[preceding-sibling::sect4]
- and ancestor::sect3[preceding-sibling::sect3]
- and ancestor::sect2[preceding-sibling::sect2]
- and ancestor::sect1[preceding-sibling::sect1]][1]
-
- |ancestor::section[$chunk.section.depth > count(ancestor::section)
- and not(ancestor::section[not(preceding-sibling::section)])][1])[last()]"/>
-
- <xsl:variable name="prev-v2"
- select="(preceding::sect1[$chunk.section.depth > 0
- and preceding-sibling::sect1][1]
-
- |preceding::sect2[$chunk.section.depth > 1
- and preceding-sibling::sect2
- and parent::sect1[preceding-sibling::sect1]][1]
-
- |preceding::sect3[$chunk.section.depth > 2
- and preceding-sibling::sect3
- and parent::sect2[preceding-sibling::sect2]
- and ancestor::sect1[preceding-sibling::sect1]][1]
-
- |preceding::sect4[$chunk.section.depth > 3
- and preceding-sibling::sect4
- and parent::sect3[preceding-sibling::sect3]
- and ancestor::sect2[preceding-sibling::sect2]
- and ancestor::sect1[preceding-sibling::sect1]][1]
-
- |preceding::sect5[$chunk.section.depth > 4
- and preceding-sibling::sect5
- and parent::sect4[preceding-sibling::sect4]
- and ancestor::sect3[preceding-sibling::sect3]
- and ancestor::sect2[preceding-sibling::sect2]
- and ancestor::sect1[preceding-sibling::sect1]][1]
-
- |preceding::section[$chunk.section.depth > count(ancestor::section)
- and preceding-sibling::section
- and not(ancestor::section[not(preceding-sibling::section)])][1])[last()]"/>
-
- <xsl:variable name="prev"
- select="(preceding::book[1]
- |preceding::preface[1]
- |preceding::chapter[1]
- |preceding::appendix[1]
- |preceding::part[1]
- |preceding::reference[1]
- |preceding::refentry[1]
- |preceding::colophon[1]
- |preceding::article[1]
- |preceding::bibliography[parent::article or parent::book or parent::part][1]
- |preceding::glossary[parent::article or parent::book or parent::part][1]
- |preceding::index[$generate.index != 0]
- [parent::article or parent::book or parent::part][1]
- |preceding::setindex[$generate.index != 0][1]
- |ancestor::set
- |ancestor::book[1]
- |ancestor::preface[1]
- |ancestor::chapter[1]
- |ancestor::appendix[1]
- |ancestor::part[1]
- |ancestor::reference[1]
- |ancestor::article[1]
- |$prev-v1
- |$prev-v2)[last()]"/>
-
- <xsl:variable name="next-v1"
- select="(following::sect1[$chunk.section.depth > 0
- and preceding-sibling::sect1][1]
-
- |following::sect2[$chunk.section.depth > 1
- and preceding-sibling::sect2
- and parent::sect1[preceding-sibling::sect1]][1]
-
- |following::sect3[$chunk.section.depth > 2
- and preceding-sibling::sect3
- and parent::sect2[preceding-sibling::sect2]
- and ancestor::sect1[preceding-sibling::sect1]][1]
-
- |following::sect4[$chunk.section.depth > 3
- and preceding-sibling::sect4
- and parent::sect3[preceding-sibling::sect3]
- and ancestor::sect2[preceding-sibling::sect2]
- and ancestor::sect1[preceding-sibling::sect1]][1]
-
- |following::sect5[$chunk.section.depth > 4
- and preceding-sibling::sect5
- and parent::sect4[preceding-sibling::sect4]
- and ancestor::sect3[preceding-sibling::sect3]
- and ancestor::sect2[preceding-sibling::sect2]
- and ancestor::sect1[preceding-sibling::sect1]][1]
-
- |following::section[$chunk.section.depth > count(ancestor::section)
- and preceding-sibling::section
- and not(ancestor::section[not(preceding-sibling::section)])][1])[1]"/>
-
- <xsl:variable name="next-v2"
- select="(descendant::sect1[$chunk.section.depth > 0
- and preceding-sibling::sect1][1]
-
- |descendant::sect2[$chunk.section.depth > 1
- and preceding-sibling::sect2
- and parent::sect1[preceding-sibling::sect1]][1]
-
- |descendant::sect3[$chunk.section.depth > 2
- and preceding-sibling::sect3
- and parent::sect2[preceding-sibling::sect2]
- and ancestor::sect1[preceding-sibling::sect1]][1]
-
- |descendant::sect4[$chunk.section.depth > 3
- and preceding-sibling::sect4
- and parent::sect3[preceding-sibling::sect3]
- and ancestor::sect2[preceding-sibling::sect2]
- and ancestor::sect1[preceding-sibling::sect1]][1]
-
- |descendant::sect5[$chunk.section.depth > 4
- and preceding-sibling::sect5
- and parent::sect4[preceding-sibling::sect4]
- and ancestor::sect3[preceding-sibling::sect3]
- and ancestor::sect2[preceding-sibling::sect2]
- and ancestor::sect1[preceding-sibling::sect1]][1]
-
- |descendant::section[$chunk.section.depth > count(ancestor::section)
- and preceding-sibling::section
- and not(ancestor::section[not(preceding-sibling::section)])])[1]"/>
-
- <xsl:variable name="next"
- select="(following::book[1]
- |following::preface[1]
- |following::chapter[1]
- |following::appendix[1]
- |following::part[1]
- |following::reference[1]
- |following::refentry[1]
- |following::colophon[1]
- |following::bibliography[parent::article or parent::book or parent::part][1]
- |following::glossary[parent::article or parent::book or parent::part][1]
- |following::index[$generate.index != 0]
- [parent::article or parent::book or parent::part][1]
- |following::article[1]
- |following::setindex[$generate.index != 0][1]
- |descendant::book[1]
- |descendant::preface[1]
- |descendant::chapter[1]
- |descendant::appendix[1]
- |descendant::article[1]
- |descendant::bibliography[parent::article or parent::book or parent::part][1]
- |descendant::glossary[parent::article or parent::book or parent::part][1]
- |descendant::index[$generate.index != 0]
- [parent::article or parent::book or parent::part][1]
- |descendant::colophon[1]
- |descendant::setindex[$generate.index != 0][1]
- |descendant::part[1]
- |descendant::reference[1]
- |descendant::refentry[1]
- |$next-v1
- |$next-v2)[1]"/>
-
- <xsl:call-template name="process-chunk">
- <xsl:with-param name="prev" select="$prev"/>
- <xsl:with-param name="next" select="$next"/>
- <xsl:with-param name="content" select="$content"/>
- </xsl:call-template>
+ <xsl:text>ix</xsl:text>
+ <xsl:number level="any" format="01" from="book"/>
+ <xsl:if test="not($recursive)">
+ <xsl:value-of select="$html.ext"/>
+ </xsl:if>
+ </xsl:when>
+
+ <xsl:when test="self::setindex">
+ <xsl:text>si</xsl:text>
+ <xsl:number level="any" format="01" from="set"/>
+ <xsl:if test="not($recursive)">
+ <xsl:value-of select="$html.ext"/>
+ </xsl:if>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <xsl:text>chunk-filename-error-</xsl:text>
+ <xsl:value-of select="name(.)"/>
+ <xsl:number level="any" format="01" from="set"/>
+ <xsl:if test="not($recursive)">
+ <xsl:value-of select="$html.ext"/>
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:template>
-<xsl:template name="chunk-all-sections">
- <xsl:param name="content">
- <xsl:apply-imports/>
- </xsl:param>
-
- <xsl:variable name="prev-v1"
- select="(preceding::sect1[$chunk.section.depth > 0][1]
- |preceding::sect2[$chunk.section.depth > 1][1]
- |preceding::sect3[$chunk.section.depth > 2][1]
- |preceding::sect4[$chunk.section.depth > 3][1]
- |preceding::sect5[$chunk.section.depth > 4][1]
- |preceding::section[$chunk.section.depth > count(ancestor::section)][1])[last()]"/>
-
- <xsl:variable name="prev-v2"
- select="(ancestor::sect1[$chunk.section.depth > 0][1]
- |ancestor::sect2[$chunk.section.depth > 1][1]
- |ancestor::sect3[$chunk.section.depth > 2][1]
- |ancestor::sect4[$chunk.section.depth > 3][1]
- |ancestor::sect5[$chunk.section.depth > 4][1]
- |ancestor::section[$chunk.section.depth > count(ancestor::section)][1])[last()]"/>
-
- <xsl:variable name="prev"
- select="(preceding::book[1]
- |preceding::preface[1]
- |preceding::chapter[1]
- |preceding::appendix[1]
- |preceding::part[1]
- |preceding::reference[1]
- |preceding::refentry[1]
- |preceding::colophon[1]
- |preceding::article[1]
- |preceding::bibliography[parent::article or parent::book or parent::part][1]
- |preceding::glossary[parent::article or parent::book or parent::part][1]
- |preceding::index[$generate.index != 0]
- [parent::article or parent::book or parent::part][1]
- |preceding::setindex[$generate.index != 0][1]
- |ancestor::set
- |ancestor::book[1]
- |ancestor::preface[1]
- |ancestor::chapter[1]
- |ancestor::appendix[1]
- |ancestor::part[1]
- |ancestor::reference[1]
- |ancestor::article[1]
- |$prev-v1
- |$prev-v2)[last()]"/>
-
- <xsl:variable name="next-v1"
- select="(following::sect1[$chunk.section.depth > 0][1]
- |following::sect2[$chunk.section.depth > 1][1]
- |following::sect3[$chunk.section.depth > 2][1]
- |following::sect4[$chunk.section.depth > 3][1]
- |following::sect5[$chunk.section.depth > 4][1]
- |following::section[$chunk.section.depth > count(ancestor::section)][1])[1]"/>
-
- <xsl:variable name="next-v2"
- select="(descendant::sect1[$chunk.section.depth > 0][1]
- |descendant::sect2[$chunk.section.depth > 1][1]
- |descendant::sect3[$chunk.section.depth > 2][1]
- |descendant::sect4[$chunk.section.depth > 3][1]
- |descendant::sect5[$chunk.section.depth > 4][1]
- |descendant::section[$chunk.section.depth
- > count(ancestor::section)][1])[1]"/>
-
- <xsl:variable name="next"
- select="(following::book[1]
- |following::preface[1]
- |following::chapter[1]
- |following::appendix[1]
- |following::part[1]
- |following::reference[1]
- |following::refentry[1]
- |following::colophon[1]
- |following::bibliography[parent::article or parent::book or parent::part][1]
- |following::glossary[parent::article or parent::book or parent::part][1]
- |following::index[$generate.index != 0]
- [parent::article or parent::book][1]
- |following::article[1]
- |following::setindex[$generate.index != 0][1]
- |descendant::book[1]
- |descendant::preface[1]
- |descendant::chapter[1]
- |descendant::appendix[1]
- |descendant::article[1]
- |descendant::bibliography[parent::article or parent::book][1]
- |descendant::glossary[parent::article or parent::book or parent::part][1]
- |descendant::index[$generate.index != 0]
- [parent::article or parent::book][1]
- |descendant::colophon[1]
- |descendant::setindex[$generate.index != 0][1]
- |descendant::part[1]
- |descendant::reference[1]
- |descendant::refentry[1]
- |$next-v1
- |$next-v2)[1]"/>
-
- <xsl:call-template name="process-chunk">
- <xsl:with-param name="prev" select="$prev"/>
- <xsl:with-param name="next" select="$next"/>
- <xsl:with-param name="content" select="$content"/>
- </xsl:call-template>
+<!-- ==================================================================== -->
+
+
+
+<xsl:template match="processing-instruction('dbhtml')">
+ <!-- nop -->
</xsl:template>
<!-- ==================================================================== -->
+
+<xsl:template match="*" mode="find.chunks">
+ <xsl:variable name="chunk">
+ <xsl:call-template name="chunk"/>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="$chunk != 0">
+ <cf:div id="{generate-id()}">
+ <xsl:apply-templates select="." mode="class.attribute"/>
+ <xsl:apply-templates select="*" mode="find.chunks"/>
+ </cf:div>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="*" mode="find.chunks"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
<xsl:template match="/">
<xsl:choose>
<!-- include extra test for Xalan quirk -->
</xsl:if>
</xsl:template>
-<!-- ==================================================================== -->
-
-<xsl:template name="make.lots">
- <xsl:param name="toc.params" select="''"/>
- <xsl:param name="toc"/>
-
- <xsl:variable name="lots">
- <xsl:if test="contains($toc.params, 'toc')">
- <xsl:copy-of select="$toc"/>
- </xsl:if>
-
- <xsl:if test="contains($toc.params, 'figure')">
- <xsl:choose>
- <xsl:when test="$chunk.separate.lots != '0'">
- <xsl:call-template name="make.lot.chunk">
- <xsl:with-param name="type" select="'figure'"/>
- <xsl:with-param name="lot">
- <xsl:call-template name="list.of.titles">
- <xsl:with-param name="titles" select="'figure'"/>
- <xsl:with-param name="nodes" select=".//figure"/>
- </xsl:call-template>
- </xsl:with-param>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="list.of.titles">
- <xsl:with-param name="titles" select="'figure'"/>
- <xsl:with-param name="nodes" select=".//figure"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
-
- <xsl:if test="contains($toc.params, 'table')">
- <xsl:choose>
- <xsl:when test="$chunk.separate.lots != '0'">
- <xsl:call-template name="make.lot.chunk">
- <xsl:with-param name="type" select="'table'"/>
- <xsl:with-param name="lot">
- <xsl:call-template name="list.of.titles">
- <xsl:with-param name="titles" select="'table'"/>
- <xsl:with-param name="nodes" select=".//table"/>
- </xsl:call-template>
- </xsl:with-param>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="list.of.titles">
- <xsl:with-param name="titles" select="'table'"/>
- <xsl:with-param name="nodes" select=".//table"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
-
- <xsl:if test="contains($toc.params, 'example')">
- <xsl:choose>
- <xsl:when test="$chunk.separate.lots != '0'">
- <xsl:call-template name="make.lot.chunk">
- <xsl:with-param name="type" select="'example'"/>
- <xsl:with-param name="lot">
- <xsl:call-template name="list.of.titles">
- <xsl:with-param name="titles" select="'example'"/>
- <xsl:with-param name="nodes" select=".//example"/>
- </xsl:call-template>
- </xsl:with-param>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="list.of.titles">
- <xsl:with-param name="titles" select="'example'"/>
- <xsl:with-param name="nodes" select=".//example"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
-
- <xsl:if test="contains($toc.params, 'equation')">
- <xsl:choose>
- <xsl:when test="$chunk.separate.lots != '0'">
- <xsl:call-template name="make.lot.chunk">
- <xsl:with-param name="type" select="'equation'"/>
- <xsl:with-param name="lot">
- <xsl:call-template name="list.of.titles">
- <xsl:with-param name="titles" select="'equation'"/>
- <xsl:with-param name="nodes" select=".//equation"/>
- </xsl:call-template>
- </xsl:with-param>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="list.of.titles">
- <xsl:with-param name="titles" select="'equation'"/>
- <xsl:with-param name="nodes" select=".//equation"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
-
- <xsl:if test="contains($toc.params, 'procedure')">
- <xsl:choose>
- <xsl:when test="$chunk.separate.lots != '0'">
- <xsl:call-template name="make.lot.chunk">
- <xsl:with-param name="type" select="'procedure'"/>
- <xsl:with-param name="lot">
- <xsl:call-template name="list.of.titles">
- <xsl:with-param name="titles" select="'procedure'"/>
- <xsl:with-param name="nodes" select=".//procedure[title]"/>
- </xsl:call-template>
- </xsl:with-param>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="list.of.titles">
- <xsl:with-param name="titles" select="'procedure'"/>
- <xsl:with-param name="nodes" select=".//procedure[title]"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
- </xsl:variable>
-
- <xsl:if test="string($lots) != ''">
- <xsl:choose>
- <xsl:when test="$chunk.tocs.and.lots != 0 and not(parent::*)">
- <xsl:call-template name="write.chunk">
- <xsl:with-param name="filename">
- <xsl:call-template name="make-relative-filename">
- <xsl:with-param name="base.dir" select="$base.dir"/>
- <xsl:with-param name="base.name">
- <xsl:call-template name="dbhtml-dir"/>
- <xsl:apply-templates select="." mode="recursive-chunk-filename">
- <xsl:with-param name="recursive" select="true()"/>
- </xsl:apply-templates>
- <xsl:text>-toc</xsl:text>
- <xsl:value-of select="$html.ext"/>
- </xsl:with-param>
- </xsl:call-template>
- </xsl:with-param>
- <xsl:with-param name="content">
- <xsl:call-template name="chunk-element-content">
- <xsl:with-param name="prev" select="/foo"/>
- <xsl:with-param name="next" select="/foo"/>
- <xsl:with-param name="nav.context" select="'toc'"/>
- <xsl:with-param name="content">
- <xsl:if test="$chunk.tocs.and.lots.has.title != 0">
- <h1>
- <xsl:apply-templates select="." mode="object.title.markup"/>
- </h1>
- </xsl:if>
- <xsl:copy-of select="$lots"/>
- </xsl:with-param>
- </xsl:call-template>
- </xsl:with-param>
- <xsl:with-param name="quiet" select="$chunk.quietly"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:copy-of select="$lots"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
-</xsl:template>
-
-<xsl:template name="make.lot.chunk">
- <xsl:param name="type" select="''"/>
- <xsl:param name="lot"/>
-
- <xsl:if test="string($lot) != ''">
- <xsl:variable name="filename">
- <xsl:call-template name="make-relative-filename">
- <xsl:with-param name="base.dir" select="$base.dir"/>
- <xsl:with-param name="base.name">
- <xsl:call-template name="dbhtml-dir"/>
- <xsl:value-of select="$type"/>
- <xsl:text>-toc</xsl:text>
- <xsl:value-of select="$html.ext"/>
- </xsl:with-param>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:variable name="href">
- <xsl:call-template name="make-relative-filename">
- <xsl:with-param name="base.name">
- <xsl:call-template name="dbhtml-dir"/>
- <xsl:value-of select="$type"/>
- <xsl:text>-toc</xsl:text>
- <xsl:value-of select="$html.ext"/>
- </xsl:with-param>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:call-template name="write.chunk">
- <xsl:with-param name="filename" select="$filename"/>
- <xsl:with-param name="content">
- <xsl:call-template name="chunk-element-content">
- <xsl:with-param name="prev" select="/foo"/>
- <xsl:with-param name="next" select="/foo"/>
- <xsl:with-param name="nav.context" select="'toc'"/>
- <xsl:with-param name="content">
- <xsl:copy-of select="$lot"/>
- </xsl:with-param>
- </xsl:call-template>
- </xsl:with-param>
- <xsl:with-param name="quiet" select="$chunk.quietly"/>
- </xsl:call-template>
- <!-- And output a link to this file -->
- <div>
- <xsl:attribute name="class">
- <xsl:text>ListofTitles</xsl:text>
- </xsl:attribute>
- <a href="{$href}">
- <xsl:call-template name="gentext">
- <xsl:with-param name="key">
- <xsl:choose>
- <xsl:when test="$type='table'">ListofTables</xsl:when>
- <xsl:when test="$type='figure'">ListofFigures</xsl:when>
- <xsl:when test="$type='equation'">ListofEquations</xsl:when>
- <xsl:when test="$type='example'">ListofExamples</xsl:when>
- <xsl:when test="$type='procedure'">ListofProcedures</xsl:when>
- <xsl:otherwise>ListofUnknown</xsl:otherwise>
- </xsl:choose>
- </xsl:with-param>
- </xsl:call-template>
- </a>
- </div>
- </xsl:if>
-</xsl:template>
-
-<!-- ==================================================================== -->
-
-<xsl:template name="in.other.chunk">
- <xsl:param name="chunk" select="."/>
- <xsl:param name="node" select="."/>
-
- <xsl:variable name="is.chunk">
- <xsl:call-template name="chunk">
- <xsl:with-param name="node" select="$node"/>
- </xsl:call-template>
- </xsl:variable>
-
-<!--
- <xsl:message>
- <xsl:text>in.other.chunk: </xsl:text>
- <xsl:value-of select="name($chunk)"/>
- <xsl:text> </xsl:text>
- <xsl:value-of select="name($node)"/>
- <xsl:text> </xsl:text>
- <xsl:value-of select="$chunk = $node"/>
- <xsl:text> </xsl:text>
- <xsl:value-of select="$is.chunk"/>
- </xsl:message>
--->
-
- <xsl:choose>
- <xsl:when test="$chunk = $node">0</xsl:when>
- <xsl:when test="$is.chunk = 1">1</xsl:when>
- <xsl:when test="count($node) = 0">0</xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="in.other.chunk">
- <xsl:with-param name="chunk" select="$chunk"/>
- <xsl:with-param name="node" select="$node/parent::*"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-
-<xsl:template name="count.footnotes.in.this.chunk">
- <xsl:param name="node" select="."/>
- <xsl:param name="footnotes" select="$node//footnote"/>
- <xsl:param name="count" select="0"/>
-
-<!--
- <xsl:message>
- <xsl:text>count.footnotes.in.this.chunk: </xsl:text>
- <xsl:value-of select="name($node)"/>
- </xsl:message>
--->
-
- <xsl:variable name="in.other.chunk">
- <xsl:call-template name="in.other.chunk">
- <xsl:with-param name="chunk" select="$node"/>
- <xsl:with-param name="node" select="$footnotes[1]"/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:choose>
- <xsl:when test="count($footnotes) = 0">
- <xsl:value-of select="$count"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when test="$in.other.chunk != 0">
- <xsl:call-template name="count.footnotes.in.this.chunk">
- <xsl:with-param name="node" select="$node"/>
- <xsl:with-param name="footnotes"
- select="$footnotes[position() > 1]"/>
- <xsl:with-param name="count" select="$count"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="$footnotes[1]/ancestor::table
- |$footnotes[1]/ancestor::informaltable">
- <xsl:call-template name="count.footnotes.in.this.chunk">
- <xsl:with-param name="node" select="$node"/>
- <xsl:with-param name="footnotes"
- select="$footnotes[position() > 1]"/>
- <xsl:with-param name="count" select="$count"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="count.footnotes.in.this.chunk">
- <xsl:with-param name="node" select="$node"/>
- <xsl:with-param name="footnotes"
- select="$footnotes[position() > 1]"/>
- <xsl:with-param name="count" select="$count + 1"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-
-<xsl:template name="process.footnotes.in.this.chunk">
- <xsl:param name="node" select="."/>
- <xsl:param name="footnotes" select="$node//footnote"/>
-
-<!--
- <xsl:message>process.footnotes.in.this.chunk</xsl:message>
--->
-
- <xsl:variable name="in.other.chunk">
- <xsl:call-template name="in.other.chunk">
- <xsl:with-param name="chunk" select="$node"/>
- <xsl:with-param name="node" select="$footnotes[1]"/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:choose>
- <xsl:when test="count($footnotes) = 0">
- <!-- nop -->
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when test="$in.other.chunk != 0">
- <xsl:call-template name="process.footnotes.in.this.chunk">
- <xsl:with-param name="node" select="$node"/>
- <xsl:with-param name="footnotes"
- select="$footnotes[position() > 1]"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="$footnotes[1]/ancestor::table
- |$footnotes[1]/ancestor::informaltable">
- <xsl:call-template name="process.footnotes.in.this.chunk">
- <xsl:with-param name="node" select="$node"/>
- <xsl:with-param name="footnotes"
- select="$footnotes[position() > 1]"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates select="$footnotes[1]"
- mode="process.footnote.mode"/>
- <xsl:call-template name="process.footnotes.in.this.chunk">
- <xsl:with-param name="node" select="$node"/>
- <xsl:with-param name="footnotes"
- select="$footnotes[position() > 1]"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-
-<xsl:template name="process.footnotes">
- <xsl:variable name="footnotes" select=".//footnote"/>
- <xsl:variable name="fcount">
- <xsl:call-template name="count.footnotes.in.this.chunk">
- <xsl:with-param name="node" select="."/>
- <xsl:with-param name="footnotes" select="$footnotes"/>
- </xsl:call-template>
- </xsl:variable>
-
-<!--
- <xsl:message>
- <xsl:value-of select="name(.)"/>
- <xsl:text> fcount: </xsl:text>
- <xsl:value-of select="$fcount"/>
- </xsl:message>
--->
-
- <!-- Only bother to do this if there's at least one non-table footnote -->
- <xsl:if test="$fcount > 0">
- <div class="footnotes">
- <br/>
- <hr width="100" align="left"/>
- <xsl:call-template name="process.footnotes.in.this.chunk">
- <xsl:with-param name="node" select="."/>
- <xsl:with-param name="footnotes" select="$footnotes"/>
- </xsl:call-template>
- </div>
- </xsl:if>
-
- <!-- FIXME: When chunking, only the annotations actually used
- in this chunk should be referenced. I don't think it
- does any harm to reference them all, but it adds
- unnecessary bloat to each chunk. -->
- <xsl:if test="$annotation.support != 0 and //annotation">
- <div class="annotation-list">
- <div class="annotation-nocss">
- <p>The following annotations are from this essay. You are seeing
- them here because your browser doesn’t support the user-interface
- techniques used to make them appear as ‘popups’ on modern browsers.</p>
- </div>
-
- <xsl:apply-templates select="//annotation"
- mode="annotation-popup"/>
- </div>
- </xsl:if>
-</xsl:template>
-
-<xsl:template name="process.chunk.footnotes">
- <xsl:variable name="is.chunk">
- <xsl:call-template name="chunk"/>
- </xsl:variable>
- <xsl:if test="$is.chunk = 1">
- <xsl:call-template name="process.footnotes"/>
- </xsl:if>
-</xsl:template>
-
-<!-- ====================================================================== -->
-
<!-- Resolve xml:base attributes -->
<xsl:template match="@fileref">
<!-- need a check for absolute urls -->
</xsl:choose>
</xsl:template>
+<!-- ==================================================================== -->
+<xsl:template match="set|book|part|preface|chapter|appendix
+ |article
+ |reference|refentry
+ |sect1|sect2|sect3|sect4|sect5
+ |section
+ |book/glossary|article/glossary|part/glossary
+ |book/bibliography|article/bibliography|part/bibliography
+ |colophon"
+ mode="enumerate-files">
+ <xsl:variable name="ischunk"><xsl:call-template name="chunk"/></xsl:variable>
+ <xsl:if test="$ischunk='1'">
+ <xsl:call-template name="make-relative-filename">
+ <xsl:with-param name="base.dir">
+ <xsl:if test="$manifest.in.base.dir = 0">
+ <xsl:value-of select="$base.dir"/>
+ </xsl:if>
+ </xsl:with-param>
+ <xsl:with-param name="base.name">
+ <xsl:apply-templates mode="chunk-filename" select="."/>
+ </xsl:with-param>
+ </xsl:call-template>
+ <xsl:text> </xsl:text>
+ </xsl:if>
+ <xsl:apply-templates select="*" mode="enumerate-files"/>
+</xsl:template>
+
+<xsl:template match="book/index|article/index|part/index"
+ mode="enumerate-files">
+ <xsl:if test="$htmlhelp.output != 1">
+ <xsl:variable name="ischunk"><xsl:call-template name="chunk"/></xsl:variable>
+ <xsl:if test="$ischunk='1'">
+ <xsl:call-template name="make-relative-filename">
+ <xsl:with-param name="base.dir">
+ <xsl:if test="$manifest.in.base.dir = 0">
+ <xsl:value-of select="$base.dir"/>
+ </xsl:if>
+ </xsl:with-param>
+ <xsl:with-param name="base.name">
+ <xsl:apply-templates mode="chunk-filename" select="."/>
+ </xsl:with-param>
+ </xsl:call-template>
+ <xsl:text> </xsl:text>
+ </xsl:if>
+ <xsl:apply-templates select="*" mode="enumerate-files"/>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match="legalnotice" mode="enumerate-files">
+ <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
+ <xsl:if test="$generate.legalnotice.link != 0">
+ <xsl:call-template name="make-relative-filename">
+ <xsl:with-param name="base.dir">
+ <xsl:if test="$manifest.in.base.dir = 0">
+ <xsl:value-of select="$base.dir"/>
+ </xsl:if>
+ </xsl:with-param>
+ <xsl:with-param name="base.name">
+ <xsl:apply-templates mode="chunk-filename" select="."/>
+ </xsl:with-param>
+ </xsl:call-template>
+ <xsl:text> </xsl:text>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match="mediaobject[imageobject] | inlinemediaobject[imageobject]" mode="enumerate-files">
+ <xsl:variable name="longdesc.uri">
+ <xsl:call-template name="longdesc.uri">
+ <xsl:with-param name="mediaobject"
+ select="."/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:variable name="mediaobject" select="."/>
+
+ <xsl:if test="$html.longdesc != 0 and $mediaobject/textobject[not(phrase)]">
+ <xsl:call-template name="longdesc.uri">
+ <xsl:with-param name="mediaobject" select="$mediaobject"/>
+ </xsl:call-template>
+ <xsl:text> </xsl:text>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match="text()" mode="enumerate-files">
+</xsl:template>
+
</xsl:stylesheet>
-<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- version="1.0">
+ xmlns:exsl="http://exslt.org/common"
+ xmlns:cf="http://docbook.sourceforge.net/xmlns/chunkfast/1.0"
+ xmlns:ng="http://docbook.org/docbook-ng"
+ xmlns:db="http://docbook.org/ns/docbook"
+ version="1.0"
+ exclude-result-prefixes="exsl cf ng db">
<!-- ********************************************************************
$Id$
<!-- ==================================================================== -->
+<xsl:param name="onechunk" select="0"/>
+<xsl:param name="refentry.separator" select="0"/>
+<xsl:param name="chunk.fast" select="0"/>
+
+<xsl:key name="genid" match="*" use="generate-id()"/>
+
+<!-- ==================================================================== -->
+
+<xsl:variable name="chunk.hierarchy">
+ <xsl:if test="$chunk.fast != 0">
+ <xsl:choose>
+ <xsl:when test="function-available('exsl:node-set')">
+ <xsl:message>Computing chunks...</xsl:message>
+ <xsl:apply-templates select="/*" mode="find.chunks"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:message>
+ <xsl:text>Fast chunking requires exsl:node-set(). </xsl:text>
+ <xsl:text>Using "slow" chunking.</xsl:text>
+ </xsl:message>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+</xsl:variable>
+
+<!-- ==================================================================== -->
+
+<xsl:template name="process-chunk-element">
+ <xsl:param name="content">
+ <xsl:apply-imports/>
+ </xsl:param>
+
+ <xsl:choose>
+ <xsl:when test="$chunk.fast != 0 and function-available('exsl:node-set')">
+ <xsl:variable name="chunks" select="exsl:node-set($chunk.hierarchy)//cf:div"/>
+ <xsl:variable name="genid" select="generate-id()"/>
+
+ <xsl:variable name="div" select="$chunks[@id=$genid or @xml:id=$genid]"/>
+
+ <xsl:variable name="prevdiv"
+ select="($div/preceding-sibling::cf:div|$div/preceding::cf:div|$div/parent::cf:div)[last()]"/>
+ <xsl:variable name="prev" select="key('genid', ($prevdiv/@id|$prevdiv/@xml:id)[1])"/>
+
+ <xsl:variable name="nextdiv"
+ select="($div/following-sibling::cf:div|$div/following::cf:div|$div/cf:div)[1]"/>
+ <xsl:variable name="next" select="key('genid', ($nextdiv/@id|$nextdiv/@xml:id)[1])"/>
+
+ <xsl:choose>
+ <xsl:when test="$onechunk != 0 and parent::*">
+ <xsl:copy-of select="$content"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="process-chunk">
+ <xsl:with-param name="prev" select="$prev"/>
+ <xsl:with-param name="next" select="$next"/>
+ <xsl:with-param name="content" select="$content"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="$onechunk != 0 and not(parent::*)">
+ <xsl:call-template name="chunk-all-sections">
+ <xsl:with-param name="content" select="$content"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="$onechunk != 0">
+ <xsl:copy-of select="$content"/>
+ </xsl:when>
+ <xsl:when test="$chunk.first.sections = 0">
+ <xsl:call-template name="chunk-first-section-with-parent">
+ <xsl:with-param name="content" select="$content"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="chunk-all-sections">
+ <xsl:with-param name="content" select="$content"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template name="process-chunk">
+ <xsl:param name="prev" select="."/>
+ <xsl:param name="next" select="."/>
+ <xsl:param name="content">
+ <xsl:apply-imports/>
+ </xsl:param>
+
+ <xsl:variable name="ischunk">
+ <xsl:call-template name="chunk"/>
+ </xsl:variable>
+
+ <xsl:variable name="chunkfn">
+ <xsl:if test="$ischunk='1'">
+ <xsl:apply-templates mode="chunk-filename" select="."/>
+ </xsl:if>
+ </xsl:variable>
+
+ <xsl:if test="$ischunk='0'">
+ <xsl:message>
+ <xsl:text>Error </xsl:text>
+ <xsl:value-of select="name(.)"/>
+ <xsl:text> is not a chunk!</xsl:text>
+ </xsl:message>
+ </xsl:if>
+
+ <xsl:variable name="filename">
+ <xsl:call-template name="make-relative-filename">
+ <xsl:with-param name="base.dir" select="$base.dir"/>
+ <xsl:with-param name="base.name" select="$chunkfn"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:call-template name="write.chunk">
+ <xsl:with-param name="filename" select="$filename"/>
+ <xsl:with-param name="content">
+ <xsl:call-template name="chunk-element-content">
+ <xsl:with-param name="prev" select="$prev"/>
+ <xsl:with-param name="next" select="$next"/>
+ <xsl:with-param name="content" select="$content"/>
+ </xsl:call-template>
+ </xsl:with-param>
+ <xsl:with-param name="quiet" select="$chunk.quietly"/>
+ </xsl:call-template>
+</xsl:template>
+
+<xsl:template name="chunk-first-section-with-parent">
+ <xsl:param name="content">
+ <xsl:apply-imports/>
+ </xsl:param>
+
+ <!-- These xpath expressions are really hairy. The trick is to pick sections -->
+ <!-- that are not first children and are not the children of first children -->
+
+ <!-- Break these variables into pieces to work around
+ http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6063 -->
+
+ <xsl:variable name="prev-v1"
+ select="(ancestor::sect1[$chunk.section.depth > 0
+ and preceding-sibling::sect1][1]
+
+ |ancestor::sect2[$chunk.section.depth > 1
+ and preceding-sibling::sect2
+ and parent::sect1[preceding-sibling::sect1]][1]
+
+ |ancestor::sect3[$chunk.section.depth > 2
+ and preceding-sibling::sect3
+ and parent::sect2[preceding-sibling::sect2]
+ and ancestor::sect1[preceding-sibling::sect1]][1]
+
+ |ancestor::sect4[$chunk.section.depth > 3
+ and preceding-sibling::sect4
+ and parent::sect3[preceding-sibling::sect3]
+ and ancestor::sect2[preceding-sibling::sect2]
+ and ancestor::sect1[preceding-sibling::sect1]][1]
+
+ |ancestor::sect5[$chunk.section.depth > 4
+ and preceding-sibling::sect5
+ and parent::sect4[preceding-sibling::sect4]
+ and ancestor::sect3[preceding-sibling::sect3]
+ and ancestor::sect2[preceding-sibling::sect2]
+ and ancestor::sect1[preceding-sibling::sect1]][1]
+
+ |ancestor::section[$chunk.section.depth > count(ancestor::section)
+ and not(ancestor::section[not(preceding-sibling::section)])][1])[last()]"/>
+
+ <xsl:variable name="prev-v2"
+ select="(preceding::sect1[$chunk.section.depth > 0
+ and preceding-sibling::sect1][1]
+
+ |preceding::sect2[$chunk.section.depth > 1
+ and preceding-sibling::sect2
+ and parent::sect1[preceding-sibling::sect1]][1]
+
+ |preceding::sect3[$chunk.section.depth > 2
+ and preceding-sibling::sect3
+ and parent::sect2[preceding-sibling::sect2]
+ and ancestor::sect1[preceding-sibling::sect1]][1]
+
+ |preceding::sect4[$chunk.section.depth > 3
+ and preceding-sibling::sect4
+ and parent::sect3[preceding-sibling::sect3]
+ and ancestor::sect2[preceding-sibling::sect2]
+ and ancestor::sect1[preceding-sibling::sect1]][1]
+
+ |preceding::sect5[$chunk.section.depth > 4
+ and preceding-sibling::sect5
+ and parent::sect4[preceding-sibling::sect4]
+ and ancestor::sect3[preceding-sibling::sect3]
+ and ancestor::sect2[preceding-sibling::sect2]
+ and ancestor::sect1[preceding-sibling::sect1]][1]
+
+ |preceding::section[$chunk.section.depth > count(ancestor::section)
+ and preceding-sibling::section
+ and not(ancestor::section[not(preceding-sibling::section)])][1])[last()]"/>
+
+ <xsl:variable name="prev"
+ select="(preceding::book[1]
+ |preceding::preface[1]
+ |preceding::chapter[1]
+ |preceding::appendix[1]
+ |preceding::part[1]
+ |preceding::reference[1]
+ |preceding::refentry[1]
+ |preceding::colophon[1]
+ |preceding::article[1]
+ |preceding::bibliography[parent::article or parent::book or parent::part][1]
+ |preceding::glossary[parent::article or parent::book or parent::part][1]
+ |preceding::index[$generate.index != 0]
+ [parent::article or parent::book or parent::part][1]
+ |preceding::setindex[$generate.index != 0][1]
+ |ancestor::set
+ |ancestor::book[1]
+ |ancestor::preface[1]
+ |ancestor::chapter[1]
+ |ancestor::appendix[1]
+ |ancestor::part[1]
+ |ancestor::reference[1]
+ |ancestor::article[1]
+ |$prev-v1
+ |$prev-v2)[last()]"/>
+
+ <xsl:variable name="next-v1"
+ select="(following::sect1[$chunk.section.depth > 0
+ and preceding-sibling::sect1][1]
+
+ |following::sect2[$chunk.section.depth > 1
+ and preceding-sibling::sect2
+ and parent::sect1[preceding-sibling::sect1]][1]
+
+ |following::sect3[$chunk.section.depth > 2
+ and preceding-sibling::sect3
+ and parent::sect2[preceding-sibling::sect2]
+ and ancestor::sect1[preceding-sibling::sect1]][1]
+
+ |following::sect4[$chunk.section.depth > 3
+ and preceding-sibling::sect4
+ and parent::sect3[preceding-sibling::sect3]
+ and ancestor::sect2[preceding-sibling::sect2]
+ and ancestor::sect1[preceding-sibling::sect1]][1]
+
+ |following::sect5[$chunk.section.depth > 4
+ and preceding-sibling::sect5
+ and parent::sect4[preceding-sibling::sect4]
+ and ancestor::sect3[preceding-sibling::sect3]
+ and ancestor::sect2[preceding-sibling::sect2]
+ and ancestor::sect1[preceding-sibling::sect1]][1]
+
+ |following::section[$chunk.section.depth > count(ancestor::section)
+ and preceding-sibling::section
+ and not(ancestor::section[not(preceding-sibling::section)])][1])[1]"/>
+
+ <xsl:variable name="next-v2"
+ select="(descendant::sect1[$chunk.section.depth > 0
+ and preceding-sibling::sect1][1]
+
+ |descendant::sect2[$chunk.section.depth > 1
+ and preceding-sibling::sect2
+ and parent::sect1[preceding-sibling::sect1]][1]
+
+ |descendant::sect3[$chunk.section.depth > 2
+ and preceding-sibling::sect3
+ and parent::sect2[preceding-sibling::sect2]
+ and ancestor::sect1[preceding-sibling::sect1]][1]
+
+ |descendant::sect4[$chunk.section.depth > 3
+ and preceding-sibling::sect4
+ and parent::sect3[preceding-sibling::sect3]
+ and ancestor::sect2[preceding-sibling::sect2]
+ and ancestor::sect1[preceding-sibling::sect1]][1]
+
+ |descendant::sect5[$chunk.section.depth > 4
+ and preceding-sibling::sect5
+ and parent::sect4[preceding-sibling::sect4]
+ and ancestor::sect3[preceding-sibling::sect3]
+ and ancestor::sect2[preceding-sibling::sect2]
+ and ancestor::sect1[preceding-sibling::sect1]][1]
+
+ |descendant::section[$chunk.section.depth > count(ancestor::section)
+ and preceding-sibling::section
+ and not(ancestor::section[not(preceding-sibling::section)])])[1]"/>
+
+ <xsl:variable name="next"
+ select="(following::book[1]
+ |following::preface[1]
+ |following::chapter[1]
+ |following::appendix[1]
+ |following::part[1]
+ |following::reference[1]
+ |following::refentry[1]
+ |following::colophon[1]
+ |following::bibliography[parent::article or parent::book or parent::part][1]
+ |following::glossary[parent::article or parent::book or parent::part][1]
+ |following::index[$generate.index != 0]
+ [parent::article or parent::book or parent::part][1]
+ |following::article[1]
+ |following::setindex[$generate.index != 0][1]
+ |descendant::book[1]
+ |descendant::preface[1]
+ |descendant::chapter[1]
+ |descendant::appendix[1]
+ |descendant::article[1]
+ |descendant::bibliography[parent::article or parent::book or parent::part][1]
+ |descendant::glossary[parent::article or parent::book or parent::part][1]
+ |descendant::index[$generate.index != 0]
+ [parent::article or parent::book or parent::part][1]
+ |descendant::colophon[1]
+ |descendant::setindex[$generate.index != 0][1]
+ |descendant::part[1]
+ |descendant::reference[1]
+ |descendant::refentry[1]
+ |$next-v1
+ |$next-v2)[1]"/>
+
+ <xsl:call-template name="process-chunk">
+ <xsl:with-param name="prev" select="$prev"/>
+ <xsl:with-param name="next" select="$next"/>
+ <xsl:with-param name="content" select="$content"/>
+ </xsl:call-template>
+</xsl:template>
+
+<xsl:template name="chunk-all-sections">
+ <xsl:param name="content">
+ <xsl:apply-imports/>
+ </xsl:param>
+
+ <xsl:variable name="prev-v1"
+ select="(preceding::sect1[$chunk.section.depth > 0][1]
+ |preceding::sect2[$chunk.section.depth > 1][1]
+ |preceding::sect3[$chunk.section.depth > 2][1]
+ |preceding::sect4[$chunk.section.depth > 3][1]
+ |preceding::sect5[$chunk.section.depth > 4][1]
+ |preceding::section[$chunk.section.depth > count(ancestor::section)][1])[last()]"/>
+
+ <xsl:variable name="prev-v2"
+ select="(ancestor::sect1[$chunk.section.depth > 0][1]
+ |ancestor::sect2[$chunk.section.depth > 1][1]
+ |ancestor::sect3[$chunk.section.depth > 2][1]
+ |ancestor::sect4[$chunk.section.depth > 3][1]
+ |ancestor::sect5[$chunk.section.depth > 4][1]
+ |ancestor::section[$chunk.section.depth > count(ancestor::section)][1])[last()]"/>
+
+ <xsl:variable name="prev"
+ select="(preceding::book[1]
+ |preceding::preface[1]
+ |preceding::chapter[1]
+ |preceding::appendix[1]
+ |preceding::part[1]
+ |preceding::reference[1]
+ |preceding::refentry[1]
+ |preceding::colophon[1]
+ |preceding::article[1]
+ |preceding::bibliography[parent::article or parent::book or parent::part][1]
+ |preceding::glossary[parent::article or parent::book or parent::part][1]
+ |preceding::index[$generate.index != 0]
+ [parent::article or parent::book or parent::part][1]
+ |preceding::setindex[$generate.index != 0][1]
+ |ancestor::set
+ |ancestor::book[1]
+ |ancestor::preface[1]
+ |ancestor::chapter[1]
+ |ancestor::appendix[1]
+ |ancestor::part[1]
+ |ancestor::reference[1]
+ |ancestor::article[1]
+ |$prev-v1
+ |$prev-v2)[last()]"/>
+
+ <xsl:variable name="next-v1"
+ select="(following::sect1[$chunk.section.depth > 0][1]
+ |following::sect2[$chunk.section.depth > 1][1]
+ |following::sect3[$chunk.section.depth > 2][1]
+ |following::sect4[$chunk.section.depth > 3][1]
+ |following::sect5[$chunk.section.depth > 4][1]
+ |following::section[$chunk.section.depth > count(ancestor::section)][1])[1]"/>
+
+ <xsl:variable name="next-v2"
+ select="(descendant::sect1[$chunk.section.depth > 0][1]
+ |descendant::sect2[$chunk.section.depth > 1][1]
+ |descendant::sect3[$chunk.section.depth > 2][1]
+ |descendant::sect4[$chunk.section.depth > 3][1]
+ |descendant::sect5[$chunk.section.depth > 4][1]
+ |descendant::section[$chunk.section.depth
+ > count(ancestor::section)][1])[1]"/>
+
+ <xsl:variable name="next"
+ select="(following::book[1]
+ |following::preface[1]
+ |following::chapter[1]
+ |following::appendix[1]
+ |following::part[1]
+ |following::reference[1]
+ |following::refentry[1]
+ |following::colophon[1]
+ |following::bibliography[parent::article or parent::book or parent::part][1]
+ |following::glossary[parent::article or parent::book or parent::part][1]
+ |following::index[$generate.index != 0]
+ [parent::article or parent::book][1]
+ |following::article[1]
+ |following::setindex[$generate.index != 0][1]
+ |descendant::book[1]
+ |descendant::preface[1]
+ |descendant::chapter[1]
+ |descendant::appendix[1]
+ |descendant::article[1]
+ |descendant::bibliography[parent::article or parent::book][1]
+ |descendant::glossary[parent::article or parent::book or parent::part][1]
+ |descendant::index[$generate.index != 0]
+ [parent::article or parent::book][1]
+ |descendant::colophon[1]
+ |descendant::setindex[$generate.index != 0][1]
+ |descendant::part[1]
+ |descendant::reference[1]
+ |descendant::refentry[1]
+ |$next-v1
+ |$next-v2)[1]"/>
+
+ <xsl:call-template name="process-chunk">
+ <xsl:with-param name="prev" select="$prev"/>
+ <xsl:with-param name="next" select="$next"/>
+ <xsl:with-param name="content" select="$content"/>
+ </xsl:call-template>
+</xsl:template>
+
+<!-- ==================================================================== -->
+
+<!-- ==================================================================== -->
+
+<xsl:template name="make.lots">
+ <xsl:param name="toc.params" select="''"/>
+ <xsl:param name="toc"/>
+
+ <xsl:variable name="lots">
+ <xsl:if test="contains($toc.params, 'toc')">
+ <xsl:copy-of select="$toc"/>
+ </xsl:if>
+
+ <xsl:if test="contains($toc.params, 'figure')">
+ <xsl:choose>
+ <xsl:when test="$chunk.separate.lots != '0'">
+ <xsl:call-template name="make.lot.chunk">
+ <xsl:with-param name="type" select="'figure'"/>
+ <xsl:with-param name="lot">
+ <xsl:call-template name="list.of.titles">
+ <xsl:with-param name="titles" select="'figure'"/>
+ <xsl:with-param name="nodes" select=".//figure"/>
+ </xsl:call-template>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="list.of.titles">
+ <xsl:with-param name="titles" select="'figure'"/>
+ <xsl:with-param name="nodes" select=".//figure"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+
+ <xsl:if test="contains($toc.params, 'table')">
+ <xsl:choose>
+ <xsl:when test="$chunk.separate.lots != '0'">
+ <xsl:call-template name="make.lot.chunk">
+ <xsl:with-param name="type" select="'table'"/>
+ <xsl:with-param name="lot">
+ <xsl:call-template name="list.of.titles">
+ <xsl:with-param name="titles" select="'table'"/>
+ <xsl:with-param name="nodes" select=".//table"/>
+ </xsl:call-template>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="list.of.titles">
+ <xsl:with-param name="titles" select="'table'"/>
+ <xsl:with-param name="nodes" select=".//table"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+
+ <xsl:if test="contains($toc.params, 'example')">
+ <xsl:choose>
+ <xsl:when test="$chunk.separate.lots != '0'">
+ <xsl:call-template name="make.lot.chunk">
+ <xsl:with-param name="type" select="'example'"/>
+ <xsl:with-param name="lot">
+ <xsl:call-template name="list.of.titles">
+ <xsl:with-param name="titles" select="'example'"/>
+ <xsl:with-param name="nodes" select=".//example"/>
+ </xsl:call-template>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="list.of.titles">
+ <xsl:with-param name="titles" select="'example'"/>
+ <xsl:with-param name="nodes" select=".//example"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+
+ <xsl:if test="contains($toc.params, 'equation')">
+ <xsl:choose>
+ <xsl:when test="$chunk.separate.lots != '0'">
+ <xsl:call-template name="make.lot.chunk">
+ <xsl:with-param name="type" select="'equation'"/>
+ <xsl:with-param name="lot">
+ <xsl:call-template name="list.of.titles">
+ <xsl:with-param name="titles" select="'equation'"/>
+ <xsl:with-param name="nodes" select=".//equation"/>
+ </xsl:call-template>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="list.of.titles">
+ <xsl:with-param name="titles" select="'equation'"/>
+ <xsl:with-param name="nodes" select=".//equation"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+
+ <xsl:if test="contains($toc.params, 'procedure')">
+ <xsl:choose>
+ <xsl:when test="$chunk.separate.lots != '0'">
+ <xsl:call-template name="make.lot.chunk">
+ <xsl:with-param name="type" select="'procedure'"/>
+ <xsl:with-param name="lot">
+ <xsl:call-template name="list.of.titles">
+ <xsl:with-param name="titles" select="'procedure'"/>
+ <xsl:with-param name="nodes" select=".//procedure[title]"/>
+ </xsl:call-template>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="list.of.titles">
+ <xsl:with-param name="titles" select="'procedure'"/>
+ <xsl:with-param name="nodes" select=".//procedure[title]"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+ </xsl:variable>
+
+ <xsl:if test="string($lots) != ''">
+ <xsl:choose>
+ <xsl:when test="$chunk.tocs.and.lots != 0 and not(parent::*)">
+ <xsl:call-template name="write.chunk">
+ <xsl:with-param name="filename">
+ <xsl:call-template name="make-relative-filename">
+ <xsl:with-param name="base.dir" select="$base.dir"/>
+ <xsl:with-param name="base.name">
+ <xsl:call-template name="dbhtml-dir"/>
+ <xsl:apply-templates select="." mode="recursive-chunk-filename">
+ <xsl:with-param name="recursive" select="true()"/>
+ </xsl:apply-templates>
+ <xsl:text>-toc</xsl:text>
+ <xsl:value-of select="$html.ext"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:with-param>
+ <xsl:with-param name="content">
+ <xsl:call-template name="chunk-element-content">
+ <xsl:with-param name="prev" select="/foo"/>
+ <xsl:with-param name="next" select="/foo"/>
+ <xsl:with-param name="nav.context" select="'toc'"/>
+ <xsl:with-param name="content">
+ <xsl:if test="$chunk.tocs.and.lots.has.title != 0">
+ <h1>
+ <xsl:apply-templates select="." mode="object.title.markup"/>
+ </h1>
+ </xsl:if>
+ <xsl:copy-of select="$lots"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:with-param>
+ <xsl:with-param name="quiet" select="$chunk.quietly"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of select="$lots"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template name="make.lot.chunk">
+ <xsl:param name="type" select="''"/>
+ <xsl:param name="lot"/>
+
+ <xsl:if test="string($lot) != ''">
+ <xsl:variable name="filename">
+ <xsl:call-template name="make-relative-filename">
+ <xsl:with-param name="base.dir" select="$base.dir"/>
+ <xsl:with-param name="base.name">
+ <xsl:call-template name="dbhtml-dir"/>
+ <xsl:value-of select="$type"/>
+ <xsl:text>-toc</xsl:text>
+ <xsl:value-of select="$html.ext"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="href">
+ <xsl:call-template name="make-relative-filename">
+ <xsl:with-param name="base.name">
+ <xsl:call-template name="dbhtml-dir"/>
+ <xsl:value-of select="$type"/>
+ <xsl:text>-toc</xsl:text>
+ <xsl:value-of select="$html.ext"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:call-template name="write.chunk">
+ <xsl:with-param name="filename" select="$filename"/>
+ <xsl:with-param name="content">
+ <xsl:call-template name="chunk-element-content">
+ <xsl:with-param name="prev" select="/foo"/>
+ <xsl:with-param name="next" select="/foo"/>
+ <xsl:with-param name="nav.context" select="'toc'"/>
+ <xsl:with-param name="content">
+ <xsl:copy-of select="$lot"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:with-param>
+ <xsl:with-param name="quiet" select="$chunk.quietly"/>
+ </xsl:call-template>
+ <!-- And output a link to this file -->
+ <div>
+ <xsl:attribute name="class">
+ <xsl:text>ListofTitles</xsl:text>
+ </xsl:attribute>
+ <a href="{$href}">
+ <xsl:call-template name="gentext">
+ <xsl:with-param name="key">
+ <xsl:choose>
+ <xsl:when test="$type='table'">ListofTables</xsl:when>
+ <xsl:when test="$type='figure'">ListofFigures</xsl:when>
+ <xsl:when test="$type='equation'">ListofEquations</xsl:when>
+ <xsl:when test="$type='example'">ListofExamples</xsl:when>
+ <xsl:when test="$type='procedure'">ListofProcedures</xsl:when>
+ <xsl:otherwise>ListofUnknown</xsl:otherwise>
+ </xsl:choose>
+ </xsl:with-param>
+ </xsl:call-template>
+ </a>
+ </div>
+ </xsl:if>
+</xsl:template>
+
+<!-- ==================================================================== -->
+
+<xsl:template name="in.other.chunk">
+ <xsl:param name="chunk" select="."/>
+ <xsl:param name="node" select="."/>
+
+ <xsl:variable name="is.chunk">
+ <xsl:call-template name="chunk">
+ <xsl:with-param name="node" select="$node"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+<!--
+ <xsl:message>
+ <xsl:text>in.other.chunk: </xsl:text>
+ <xsl:value-of select="name($chunk)"/>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="name($node)"/>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="$chunk = $node"/>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="$is.chunk"/>
+ </xsl:message>
+-->
+
+ <xsl:choose>
+ <xsl:when test="$chunk = $node">0</xsl:when>
+ <xsl:when test="$is.chunk = 1">1</xsl:when>
+ <xsl:when test="count($node) = 0">0</xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="in.other.chunk">
+ <xsl:with-param name="chunk" select="$chunk"/>
+ <xsl:with-param name="node" select="$node/parent::*"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template name="count.footnotes.in.this.chunk">
+ <xsl:param name="node" select="."/>
+ <xsl:param name="footnotes" select="$node//footnote"/>
+ <xsl:param name="count" select="0"/>
+
+<!--
+ <xsl:message>
+ <xsl:text>count.footnotes.in.this.chunk: </xsl:text>
+ <xsl:value-of select="name($node)"/>
+ </xsl:message>
+-->
+
+ <xsl:variable name="in.other.chunk">
+ <xsl:call-template name="in.other.chunk">
+ <xsl:with-param name="chunk" select="$node"/>
+ <xsl:with-param name="node" select="$footnotes[1]"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="count($footnotes) = 0">
+ <xsl:value-of select="$count"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="$in.other.chunk != 0">
+ <xsl:call-template name="count.footnotes.in.this.chunk">
+ <xsl:with-param name="node" select="$node"/>
+ <xsl:with-param name="footnotes"
+ select="$footnotes[position() > 1]"/>
+ <xsl:with-param name="count" select="$count"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="$footnotes[1]/ancestor::table
+ |$footnotes[1]/ancestor::informaltable">
+ <xsl:call-template name="count.footnotes.in.this.chunk">
+ <xsl:with-param name="node" select="$node"/>
+ <xsl:with-param name="footnotes"
+ select="$footnotes[position() > 1]"/>
+ <xsl:with-param name="count" select="$count"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="count.footnotes.in.this.chunk">
+ <xsl:with-param name="node" select="$node"/>
+ <xsl:with-param name="footnotes"
+ select="$footnotes[position() > 1]"/>
+ <xsl:with-param name="count" select="$count + 1"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template name="process.footnotes.in.this.chunk">
+ <xsl:param name="node" select="."/>
+ <xsl:param name="footnotes" select="$node//footnote"/>
+
+<!--
+ <xsl:message>process.footnotes.in.this.chunk</xsl:message>
+-->
+
+ <xsl:variable name="in.other.chunk">
+ <xsl:call-template name="in.other.chunk">
+ <xsl:with-param name="chunk" select="$node"/>
+ <xsl:with-param name="node" select="$footnotes[1]"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="count($footnotes) = 0">
+ <!-- nop -->
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="$in.other.chunk != 0">
+ <xsl:call-template name="process.footnotes.in.this.chunk">
+ <xsl:with-param name="node" select="$node"/>
+ <xsl:with-param name="footnotes"
+ select="$footnotes[position() > 1]"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="$footnotes[1]/ancestor::table
+ |$footnotes[1]/ancestor::informaltable">
+ <xsl:call-template name="process.footnotes.in.this.chunk">
+ <xsl:with-param name="node" select="$node"/>
+ <xsl:with-param name="footnotes"
+ select="$footnotes[position() > 1]"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="$footnotes[1]"
+ mode="process.footnote.mode"/>
+ <xsl:call-template name="process.footnotes.in.this.chunk">
+ <xsl:with-param name="node" select="$node"/>
+ <xsl:with-param name="footnotes"
+ select="$footnotes[position() > 1]"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template name="process.footnotes">
+ <xsl:variable name="footnotes" select=".//footnote"/>
+ <xsl:variable name="fcount">
+ <xsl:call-template name="count.footnotes.in.this.chunk">
+ <xsl:with-param name="node" select="."/>
+ <xsl:with-param name="footnotes" select="$footnotes"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+<!--
+ <xsl:message>
+ <xsl:value-of select="name(.)"/>
+ <xsl:text> fcount: </xsl:text>
+ <xsl:value-of select="$fcount"/>
+ </xsl:message>
+-->
+
+ <!-- Only bother to do this if there's at least one non-table footnote -->
+ <xsl:if test="$fcount > 0">
+ <div class="footnotes">
+ <br/>
+ <hr width="100" align="left"/>
+ <xsl:call-template name="process.footnotes.in.this.chunk">
+ <xsl:with-param name="node" select="."/>
+ <xsl:with-param name="footnotes" select="$footnotes"/>
+ </xsl:call-template>
+ </div>
+ </xsl:if>
+
+ <!-- FIXME: When chunking, only the annotations actually used
+ in this chunk should be referenced. I don't think it
+ does any harm to reference them all, but it adds
+ unnecessary bloat to each chunk. -->
+ <xsl:if test="$annotation.support != 0 and //annotation">
+ <div class="annotation-list">
+ <div class="annotation-nocss">
+ <p>The following annotations are from this essay. You are seeing
+ them here because your browser doesn’t support the user-interface
+ techniques used to make them appear as ‘popups’ on modern browsers.</p>
+ </div>
+
+ <xsl:apply-templates select="//annotation"
+ mode="annotation-popup"/>
+ </div>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template name="process.chunk.footnotes">
+ <xsl:variable name="is.chunk">
+ <xsl:call-template name="chunk"/>
+ </xsl:variable>
+ <xsl:if test="$is.chunk = 1">
+ <xsl:call-template name="process.footnotes"/>
+ </xsl:if>
+</xsl:template>
+
+<!-- ====================================================================== -->
+
<xsl:template name="chunk">
<xsl:param name="node" select="."/>
<!-- returns 1 if $node is a chunk -->
</xsl:template>
<!-- ==================================================================== -->
-
-<xsl:template match="*" mode="chunk-filename">
- <!-- returns the filename of a chunk -->
- <xsl:variable name="ischunk">
- <xsl:call-template name="chunk"/>
- </xsl:variable>
-
- <xsl:variable name="fn">
- <xsl:apply-templates select="." mode="recursive-chunk-filename"/>
- </xsl:variable>
-
- <!--
- <xsl:message>
- <xsl:value-of select="$ischunk"/>
- <xsl:text> (</xsl:text>
- <xsl:value-of select="local-name(.)"/>
- <xsl:text>) </xsl:text>
- <xsl:value-of select="$fn"/>
- <xsl:text>, </xsl:text>
- <xsl:call-template name="dbhtml-dir"/>
- </xsl:message>
- -->
-
- <!-- 2003-11-25 by ndw:
- The following test used to read test="$ischunk != 0 and $fn != ''"
- I've removed the ischunk part of the test so that href.to.uri and
- href.from.uri will be fully qualified even if the source or target
- isn't a chunk. I *think* that if $fn != '' then it's appropriate
- to put the directory on the front, even if the element isn't a
- chunk. I could be wrong. -->
-
- <xsl:if test="$fn != ''">
- <xsl:call-template name="dbhtml-dir"/>
- </xsl:if>
-
- <xsl:value-of select="$fn"/>
- <!-- You can't add the html.ext here because dbhtml filename= may already -->
- <!-- have added it. It really does have to be handled in the recursive template -->
-</xsl:template>
-
-<xsl:template match="*" mode="recursive-chunk-filename">
- <xsl:param name="recursive" select="false()"/>
-
- <!-- returns the filename of a chunk -->
- <xsl:variable name="ischunk">
- <xsl:call-template name="chunk"/>
- </xsl:variable>
-
- <xsl:variable name="dbhtml-filename">
- <xsl:call-template name="dbhtml-filename"/>
- </xsl:variable>
-
- <xsl:variable name="filename">
- <xsl:choose>
- <xsl:when test="$dbhtml-filename != ''">
- <xsl:value-of select="$dbhtml-filename"/>
- </xsl:when>
- <!-- if this is the root element, use the root.filename -->
- <xsl:when test="not(parent::*) and $root.filename != ''">
- <xsl:value-of select="$root.filename"/>
- <xsl:value-of select="$html.ext"/>
- </xsl:when>
- <!-- Special case -->
- <xsl:when test="self::legalnotice and $generate.legalnotice.link != 0">
- <xsl:variable name="id">
- <xsl:call-template name="object.id"/>
- </xsl:variable>
- <xsl:value-of select="concat('ln-',$id,$html.ext)"/>
- </xsl:when>
- <!-- if there's no dbhtml filename, and if we're to use IDs as -->
- <!-- filenames, then use the ID to generate the filename. -->
- <xsl:when test="(@id or @xml:id) and $use.id.as.filename != 0">
- <xsl:value-of select="(@id|@xml:id)[1]"/>
- <xsl:value-of select="$html.ext"/>
- </xsl:when>
- <xsl:otherwise></xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:choose>
- <xsl:when test="$ischunk='0'">
- <!-- if called on something that isn't a chunk, walk up... -->
- <xsl:choose>
- <xsl:when test="count(parent::*)>0">
- <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
- <xsl:with-param name="recursive" select="$recursive"/>
- </xsl:apply-templates>
- </xsl:when>
- <!-- unless there is no up, in which case return "" -->
- <xsl:otherwise></xsl:otherwise>
- </xsl:choose>
- </xsl:when>
-
- <xsl:when test="not($recursive) and $filename != ''">
- <!-- if this chunk has an explicit name, use it -->
- <xsl:value-of select="$filename"/>
- </xsl:when>
-
- <xsl:when test="self::set">
- <xsl:value-of select="$root.filename"/>
- <xsl:if test="not($recursive)">
- <xsl:value-of select="$html.ext"/>
- </xsl:if>
- </xsl:when>
-
- <xsl:when test="self::book">
- <xsl:text>bk</xsl:text>
- <xsl:number level="any" format="01"/>
- <xsl:if test="not($recursive)">
- <xsl:value-of select="$html.ext"/>
- </xsl:if>
- </xsl:when>
-
- <xsl:when test="self::article">
- <xsl:if test="/set">
- <!-- in a set, make sure we inherit the right book info... -->
- <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
- <xsl:with-param name="recursive" select="true()"/>
- </xsl:apply-templates>
- </xsl:if>
-
- <xsl:text>ar</xsl:text>
- <xsl:number level="any" format="01" from="book"/>
- <xsl:if test="not($recursive)">
- <xsl:value-of select="$html.ext"/>
- </xsl:if>
- </xsl:when>
-
- <xsl:when test="self::preface">
- <xsl:if test="/set">
- <!-- in a set, make sure we inherit the right book info... -->
- <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
- <xsl:with-param name="recursive" select="true()"/>
- </xsl:apply-templates>
- </xsl:if>
-
- <xsl:text>pr</xsl:text>
- <xsl:number level="any" format="01" from="book"/>
- <xsl:if test="not($recursive)">
- <xsl:value-of select="$html.ext"/>
- </xsl:if>
- </xsl:when>
-
- <xsl:when test="self::chapter">
- <xsl:if test="/set">
- <!-- in a set, make sure we inherit the right book info... -->
- <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
- <xsl:with-param name="recursive" select="true()"/>
- </xsl:apply-templates>
- </xsl:if>
-
- <xsl:text>ch</xsl:text>
- <xsl:number level="any" format="01" from="book"/>
- <xsl:if test="not($recursive)">
- <xsl:value-of select="$html.ext"/>
- </xsl:if>
- </xsl:when>
-
- <xsl:when test="self::appendix">
- <xsl:if test="/set">
- <!-- in a set, make sure we inherit the right book info... -->
- <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
- <xsl:with-param name="recursive" select="true()"/>
- </xsl:apply-templates>
- </xsl:if>
-
- <xsl:text>ap</xsl:text>
- <xsl:number level="any" format="a" from="book"/>
- <xsl:if test="not($recursive)">
- <xsl:value-of select="$html.ext"/>
- </xsl:if>
- </xsl:when>
-
- <xsl:when test="self::part">
- <xsl:choose>
- <xsl:when test="/set">
- <!-- in a set, make sure we inherit the right book info... -->
- <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
- <xsl:with-param name="recursive" select="true()"/>
- </xsl:apply-templates>
- </xsl:when>
- <xsl:otherwise>
- </xsl:otherwise>
- </xsl:choose>
-
- <xsl:text>pt</xsl:text>
- <xsl:number level="any" format="01" from="book"/>
- <xsl:if test="not($recursive)">
- <xsl:value-of select="$html.ext"/>
- </xsl:if>
- </xsl:when>
-
- <xsl:when test="self::reference">
- <xsl:choose>
- <xsl:when test="/set">
- <!-- in a set, make sure we inherit the right book info... -->
- <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
- <xsl:with-param name="recursive" select="true()"/>
- </xsl:apply-templates>
- </xsl:when>
- <xsl:otherwise>
- </xsl:otherwise>
- </xsl:choose>
-
- <xsl:text>rn</xsl:text>
- <xsl:number level="any" format="01" from="book"/>
- <xsl:if test="not($recursive)">
- <xsl:value-of select="$html.ext"/>
- </xsl:if>
- </xsl:when>
-
- <xsl:when test="self::refentry">
- <xsl:choose>
- <xsl:when test="parent::reference">
- <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
- <xsl:with-param name="recursive" select="true()"/>
- </xsl:apply-templates>
- </xsl:when>
- <xsl:otherwise>
- </xsl:otherwise>
- </xsl:choose>
-
- <xsl:text>re</xsl:text>
- <xsl:number level="any" format="01" from="book"/>
- <xsl:if test="not($recursive)">
- <xsl:value-of select="$html.ext"/>
- </xsl:if>
- </xsl:when>
-
- <xsl:when test="self::colophon">
- <xsl:choose>
- <xsl:when test="/set">
- <!-- in a set, make sure we inherit the right book info... -->
- <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
- <xsl:with-param name="recursive" select="true()"/>
- </xsl:apply-templates>
- </xsl:when>
- <xsl:otherwise>
- </xsl:otherwise>
- </xsl:choose>
-
- <xsl:text>co</xsl:text>
- <xsl:number level="any" format="01" from="book"/>
- <xsl:if test="not($recursive)">
- <xsl:value-of select="$html.ext"/>
- </xsl:if>
- </xsl:when>
-
- <xsl:when test="self::sect1
- or self::sect2
- or self::sect3
- or self::sect4
- or self::sect5
- or self::section">
- <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
- <xsl:with-param name="recursive" select="true()"/>
- </xsl:apply-templates>
- <xsl:text>s</xsl:text>
- <xsl:number format="01"/>
- <xsl:if test="not($recursive)">
- <xsl:value-of select="$html.ext"/>
- </xsl:if>
- </xsl:when>
-
- <xsl:when test="self::bibliography">
- <xsl:choose>
- <xsl:when test="/set">
- <!-- in a set, make sure we inherit the right book info... -->
- <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
- <xsl:with-param name="recursive" select="true()"/>
- </xsl:apply-templates>
- </xsl:when>
- <xsl:otherwise>
- </xsl:otherwise>
- </xsl:choose>
-
- <xsl:text>bi</xsl:text>
- <xsl:number level="any" format="01" from="book"/>
- <xsl:if test="not($recursive)">
- <xsl:value-of select="$html.ext"/>
- </xsl:if>
- </xsl:when>
-
- <xsl:when test="self::glossary">
- <xsl:choose>
- <xsl:when test="/set">
- <!-- in a set, make sure we inherit the right book info... -->
- <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
- <xsl:with-param name="recursive" select="true()"/>
- </xsl:apply-templates>
- </xsl:when>
- <xsl:otherwise>
- </xsl:otherwise>
- </xsl:choose>
-
- <xsl:text>go</xsl:text>
- <xsl:number level="any" format="01" from="book"/>
- <xsl:if test="not($recursive)">
- <xsl:value-of select="$html.ext"/>
- </xsl:if>
- </xsl:when>
-
- <xsl:when test="self::index">
- <xsl:choose>
- <xsl:when test="/set">
- <!-- in a set, make sure we inherit the right book info... -->
- <xsl:apply-templates mode="recursive-chunk-filename" select="parent::*">
- <xsl:with-param name="recursive" select="true()"/>
- </xsl:apply-templates>
- </xsl:when>
- <xsl:otherwise>
- </xsl:otherwise>
- </xsl:choose>
-
- <xsl:text>ix</xsl:text>
- <xsl:number level="any" format="01" from="book"/>
- <xsl:if test="not($recursive)">
- <xsl:value-of select="$html.ext"/>
- </xsl:if>
- </xsl:when>
-
- <xsl:when test="self::setindex">
- <xsl:text>si</xsl:text>
- <xsl:number level="any" format="01" from="set"/>
- <xsl:if test="not($recursive)">
- <xsl:value-of select="$html.ext"/>
- </xsl:if>
- </xsl:when>
-
- <xsl:otherwise>
- <xsl:text>chunk-filename-error-</xsl:text>
- <xsl:value-of select="name(.)"/>
- <xsl:number level="any" format="01" from="set"/>
- <xsl:if test="not($recursive)">
- <xsl:value-of select="$html.ext"/>
- </xsl:if>
- </xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-
-<!-- ==================================================================== -->
-
<xsl:template name="href.target.uri">
<xsl:param name="object" select="."/>
<xsl:variable name="ischunk">
</xsl:template>
<!-- ==================================================================== -->
-
-<xsl:template match="processing-instruction('dbhtml')">
- <!-- nop -->
-</xsl:template>
-
-<!-- ==================================================================== -->
-
<xsl:template name="chunk-element-content">
<xsl:param name="prev"/>
<xsl:param name="next"/>
<xsl:value-of select="$chunk.append"/>
</xsl:template>
+<!-- ==================================================================== -->
+<xsl:template name="generate.manifest">
+ <xsl:param name="node" select="/"/>
+ <xsl:call-template name="write.text.chunk">
+ <xsl:with-param name="filename">
+ <xsl:if test="$manifest.in.base.dir != 0">
+ <xsl:value-of select="$base.dir"/>
+ </xsl:if>
+ <xsl:value-of select="$manifest"/>
+ </xsl:with-param>
+ <xsl:with-param name="method" select="'text'"/>
+ <xsl:with-param name="content">
+ <xsl:apply-templates select="$node" mode="enumerate-files"/>
+ </xsl:with-param>
+ <xsl:with-param name="encoding" select="$chunker.output.encoding"/>
+ </xsl:call-template>
+</xsl:template>
+
</xsl:stylesheet>
<!-- ==================================================================== -->
+<!-- First import the non-chunking templates that format elements
+ within each chunk file. In a customization, you should
+ create a separate non-chunking customization layer such
+ as mydocbook.xsl that imports the original docbook.xsl and
+ customizes any presentation templates. Then your chunking
+ customization should import mydocbook.xsl instead of
+ docbook.xsl. -->
<xsl:import href="docbook.xsl"/>
-<xsl:import href="chunk-common.xsl"/>
-<xsl:include href="manifest.xsl"/>
-
-<!-- Why is chunk-code now xsl:included?
-
-Suppose you want to customize *both* the chunking algorithm used *and* the
-presentation of some elements that may be chunks. In order to do that, you
-must get the order of imports "just right". The answer is to make your own
-copy of this file, where you replace the initial import of "docbook.xsl"
-with an import of your own base.xsl (that does its own import of docbook.xsl).
-
-Put the templates for changing the presentation of elements in your base.xsl.
-Put the templates that control chunking after the include of chunk-code.xsl.
-
-Voila! (Man I hope we can do this better in XSLT 2.0)
-
--->
+<!-- chunk-common.xsl contains all the named templates for chunking.
+ In a customization file, you import chunk-common.xsl, then
+ add any customized chunking templates of the same name.
+ They will have import precedence over the original
+ chunking templates in chunk-common.xsl. -->
+<xsl:import href="chunk-common.xsl"/>
+<!-- The manifest.xsl module is no longer imported because its
+ templates were moved into chunk-common and chunk-code -->
+
+<!-- chunk-code.xsl contains all the chunking templates that use
+ a match attribute. In a customization it should be referenced
+ using <xsl:include> instead of <xsl:import>, and then add
+ any customized chunking templates with match attributes. But be sure
+ to add a priority="1" to such customized templates to resolve
+ its conflict with the original, since they have the
+ same import precedence.
+
+ Using xsl:include prevents adding another layer
+ of import precedence, which would cause any
+ customizations that use xsl:apply-imports to wrongly
+ apply the chunking version instead of the original
+ non-chunking version to format an element. -->
<xsl:include href="chunk-code.xsl"/>
</xsl:stylesheet>
******************************************************************** -->
<!-- ==================================================================== -->
+<!-- OBSOLETE. The templates from this file were moved to -->
+<!-- chunk-common.xsl and chunk-code.xsl. -->
+<!-- ==================================================================== -->
-<xsl:variable name="manifest.base.dir">
-</xsl:variable>
-
-<xsl:template name="generate.manifest">
- <xsl:param name="node" select="/"/>
- <xsl:call-template name="write.text.chunk">
- <xsl:with-param name="filename">
- <xsl:if test="$manifest.in.base.dir != 0">
- <xsl:value-of select="$base.dir"/>
- </xsl:if>
- <xsl:value-of select="$manifest"/>
- </xsl:with-param>
- <xsl:with-param name="method" select="'text'"/>
- <xsl:with-param name="content">
- <xsl:apply-templates select="$node" mode="enumerate-files"/>
- </xsl:with-param>
- <xsl:with-param name="encoding" select="$chunker.output.encoding"/>
- </xsl:call-template>
-</xsl:template>
-
-<xsl:template match="set|book|part|preface|chapter|appendix
- |article
- |reference|refentry
- |sect1|sect2|sect3|sect4|sect5
- |section
- |book/glossary|article/glossary|part/glossary
- |book/bibliography|article/bibliography|part/bibliography
- |colophon"
- mode="enumerate-files">
- <xsl:variable name="ischunk"><xsl:call-template name="chunk"/></xsl:variable>
- <xsl:if test="$ischunk='1'">
- <xsl:call-template name="make-relative-filename">
- <xsl:with-param name="base.dir">
- <xsl:if test="$manifest.in.base.dir = 0">
- <xsl:value-of select="$base.dir"/>
- </xsl:if>
- </xsl:with-param>
- <xsl:with-param name="base.name">
- <xsl:apply-templates mode="chunk-filename" select="."/>
- </xsl:with-param>
- </xsl:call-template>
- <xsl:text> </xsl:text>
- </xsl:if>
- <xsl:apply-templates select="*" mode="enumerate-files"/>
-</xsl:template>
-
-<xsl:template match="book/index|article/index|part/index"
- mode="enumerate-files">
- <xsl:if test="$htmlhelp.output != 1">
- <xsl:variable name="ischunk"><xsl:call-template name="chunk"/></xsl:variable>
- <xsl:if test="$ischunk='1'">
- <xsl:call-template name="make-relative-filename">
- <xsl:with-param name="base.dir">
- <xsl:if test="$manifest.in.base.dir = 0">
- <xsl:value-of select="$base.dir"/>
- </xsl:if>
- </xsl:with-param>
- <xsl:with-param name="base.name">
- <xsl:apply-templates mode="chunk-filename" select="."/>
- </xsl:with-param>
- </xsl:call-template>
- <xsl:text> </xsl:text>
- </xsl:if>
- <xsl:apply-templates select="*" mode="enumerate-files"/>
- </xsl:if>
-</xsl:template>
-
-<xsl:template match="legalnotice" mode="enumerate-files">
- <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
- <xsl:if test="$generate.legalnotice.link != 0">
- <xsl:call-template name="make-relative-filename">
- <xsl:with-param name="base.dir">
- <xsl:if test="$manifest.in.base.dir = 0">
- <xsl:value-of select="$base.dir"/>
- </xsl:if>
- </xsl:with-param>
- <xsl:with-param name="base.name">
- <xsl:apply-templates mode="chunk-filename" select="."/>
- </xsl:with-param>
- </xsl:call-template>
- <xsl:text> </xsl:text>
- </xsl:if>
-</xsl:template>
-
-<xsl:template match="mediaobject[imageobject] | inlinemediaobject[imageobject]" mode="enumerate-files">
- <xsl:variable name="longdesc.uri">
- <xsl:call-template name="longdesc.uri">
- <xsl:with-param name="mediaobject"
- select="."/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name="mediaobject" select="."/>
-
- <xsl:if test="$html.longdesc != 0 and $mediaobject/textobject[not(phrase)]">
- <xsl:call-template name="longdesc.uri">
- <xsl:with-param name="mediaobject" select="$mediaobject"/>
- </xsl:call-template>
- <xsl:text> </xsl:text>
- </xsl:if>
-</xsl:template>
-
-<xsl:template match="text()" mode="enumerate-files">
-</xsl:template>
</xsl:stylesheet>