]> granicus.if.org Git - docbook-dsssl/commitdiff
Check in epub3 beta2 development files.
authorBob Stayton <bobs@sagehill.net>
Thu, 22 Sep 2011 10:37:38 +0000 (10:37 +0000)
committerBob Stayton <bobs@sagehill.net>
Thu, 22 Sep 2011 10:37:38 +0000 (10:37 +0000)
xsl/epub3/chunk.xsl [new file with mode: 0644]
xsl/epub3/chunkfast.xsl [new file with mode: 0644]
xsl/epub3/docbook-epub.css.xml [new file with mode: 0644]
xsl/epub3/docbook.xsl [new file with mode: 0644]
xsl/epub3/epub3-chunk-mods.xsl [new file with mode: 0644]
xsl/epub3/epub3-element-mods.xsl [new file with mode: 0644]
xsl/epub3/profile-chunk.xsl [new file with mode: 0644]
xsl/epub3/profile-docbook.xsl [new file with mode: 0644]
xsl/epub3/titlepage.templates.xml [new file with mode: 0644]

diff --git a/xsl/epub3/chunk.xsl b/xsl/epub3/chunk.xsl
new file mode 100644 (file)
index 0000000..be062b5
--- /dev/null
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xsl:stylesheet 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+  xmlns:exsl="http://exslt.org/common"
+  xmlns:epub="http://www.idpf.org/2007/ops"
+  exclude-result-prefixes="exsl"
+  version="1.0">
+
+<!-- $Id: chunk.xsl,v 1.1 2011-09-16 21:43:45 bobs Exp $ -->
+
+<!-- This is the main driver stylesheet file.  It imports or
+includes all the components that it needs. -->
+
+<!-- Import the module that customizes docbook elements -->
+<!-- Put any customizations of element content in this module. -->
+<xsl:import href="docbook.xsl"/>
+
+<xsl:import href="../xhtml/chunk-common.xsl"/>
+
+<xsl:include href="../xhtml/chunk-code.xsl"/>
+
+<!-- The following module has templates that override the stock
+     xhtml templates for HTML5 output.  
+     It contains match templates with priority="1" attributes,
+     and named templates.  These override any templates that
+     handle chunking behavior -->
+<xsl:include href="epub3-chunk-mods.xsl"/>
+
+</xsl:stylesheet>
diff --git a/xsl/epub3/chunkfast.xsl b/xsl/epub3/chunkfast.xsl
new file mode 100644 (file)
index 0000000..8ec9550
--- /dev/null
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--This file was created automatically by html2xhtml-->
+<!--from the HTML stylesheets.-->
+<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="http://www.w3.org/1999/xhtml" version="1.0" exclude-result-prefixes="cf exsl">
+
+<!-- ********************************************************************
+     $Id: chunkfast.xsl,v 1.1 2011-09-16 21:43:45 bobs Exp $
+     ********************************************************************
+
+     This file is part of the XSL DocBook Stylesheet distribution.
+     See ../README or http://docbook.sf.net/release/xsl/current/ for
+     copyright and other information.
+
+     ******************************************************************** -->
+
+<!-- ==================================================================== -->
+
+<xsl:import href="chunk.xsl"/>
+<xsl:param name="chunk.fast" select="1"/>
+
+<xsl:variable name="chunks" select="exsl:node-set($chunk.hierarchy)//cf:div"/>
+
+<!-- ==================================================================== -->
+
+<xsl:template name="process-chunk-element">
+  <xsl:choose>
+    <xsl:when test="$chunk.fast != 0 and $exsl.node.set.available != 0">
+      <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:apply-imports/>
+        </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: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:when>
+        <xsl:when test="$onechunk != 0">
+          <xsl:apply-imports/>
+        </xsl:when>
+        <xsl:when test="$chunk.first.sections = 0">
+          <xsl:call-template name="chunk-first-section-with-parent"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:call-template name="chunk-all-sections"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/xsl/epub3/docbook-epub.css.xml b/xsl/epub3/docbook-epub.css.xml
new file mode 100644 (file)
index 0000000..cab6896
--- /dev/null
@@ -0,0 +1,143 @@
+<?xml version="1.0"?>
+<style>
+
+/********************************/
+/* start of styles in block.xsl */
+
+.formalpara-title {
+  font-weight: bold;
+}
+
+div.blockquote-title {
+  font-weight: bold;
+  margin-top: 1em;
+  margin-bottom: 1em;
+}
+
+span.msgmain-title {
+  font-weight: bold;
+}
+
+span.msgsub-title {
+  font-weight: bold;
+}
+
+span.msgrel-title {
+  font-weight: bold;
+}
+
+div.msglevel, div.msgorig, div.msgaud {
+  margin-top: 1em;
+  margin-bottom: 1em;
+}
+
+span.msglevel-title, span.msgorig-title, span.msgaud-title {
+  font-weight: bold;
+}
+
+div.msgexplan {
+  margin-top: 1em;
+  margin-bottom: 1em;
+}
+
+span.msgexplan-title {
+  font-weight: bold;
+}
+
+div.sidebar {
+  border: 0.5pt solid black;
+  margin-top: 1em;
+  margin-bottom: 1em;
+  padding: 8px;
+}
+
+/* end of styles in block.xsl */
+/********************************/
+
+/********************************/
+/* start of styles in autotoc.xsl */
+
+/* top level entries are bold */
+nav>ol>li>a {
+  font-weight: bold;
+  margin-top: 1em;
+  margin-bottom: 1em;
+}
+
+
+/* end of styles in autotoc.xsl */
+/********************************/
+
+/********************************/
+/* start of styles in formal.xsl */
+
+div.figure-title {
+  font-weight: bold;
+}
+
+div.example-title {
+  font-weight: bold;
+}
+
+div.equation-title {
+  font-weight: bold;
+}
+
+div.table-title {
+  font-weight: bold;
+}
+
+div.sidebar-title {
+  font-weight: bold;
+}
+
+
+/* end of styles in formal.xsl */
+/********************************/
+
+/********************************/
+/* start of styles in verbatim.xsl */
+
+div.programlisting {
+  white-space: pre;
+  font-family: monospace;
+}
+
+div.screen {
+  white-space: pre;
+  font-family: monospace;
+}
+
+div.synopsis {
+  white-space: pre;
+  font-family: monospace;
+}
+
+/* end of styles in verbatim.xsl */
+/********************************/
+
+/********************************/
+/* NAVIGATION */
+
+nav ol {
+list-style-type: none;
+margin: 0 0 0 2em;
+padding: 0 0 0 0;
+}
+
+nav ol li {
+margin: 0 0 0 0;
+padding: 0 0 0 0;
+}
+
+nav ol li a {
+text-decoration: none;
+color: black;
+font-family: sans-serif;
+}
+
+#guide {
+display: none;
+}
+
+</style>
diff --git a/xsl/epub3/docbook.xsl b/xsl/epub3/docbook.xsl
new file mode 100644 (file)
index 0000000..af099b8
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE xsl:stylesheet [
+<!ENTITY uppercase "'ABCDEFGHIJKLMNOPQRSTUVWXYZ'">
+<!ENTITY lowercase "'abcdefghijklmnopqrstuvwxyz'">
+]>
+
+<xsl:stylesheet 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+  xmlns="http://www.w3.org/1999/xhtml"
+  exclude-result-prefixes="#default"
+  version="1.0">
+
+<!-- $Id: docbook.xsl,v 1.1 2011-09-16 21:43:45 bobs Exp $ -->
+
+<xsl:import href="../xhtml5/docbook.xsl"/>
+
+<xsl:include href="epub3-element-mods.xsl"/>
+
+</xsl:stylesheet>
diff --git a/xsl/epub3/epub3-chunk-mods.xsl b/xsl/epub3/epub3-chunk-mods.xsl
new file mode 100644 (file)
index 0000000..b4ea68d
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xsl:stylesheet 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+  xmlns:exsl="http://exslt.org/common"
+  xmlns:epub="http://www.idpf.org/2007/ops"
+  xmlns:dc="http://purl.org/dc/elements/1.1/"  
+  xmlns:ncx="http://www.daisy.org/z3986/2005/ncx/"
+  xmlns:db="http://docbook.org/ns/docbook"
+  xmlns:opf="http://www.idpf.org/2007/opf"
+  xmlns:stext="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.TextFactory"
+  xmlns:str="http://exslt.org/strings"
+  xmlns:xtext="xalan://com.nwalsh.xalan.Text"
+  extension-element-prefixes="stext xtext"
+  exclude-result-prefixes="exsl dc ncx opf stext str xtext"
+  version="1.0">
+
+<!-- $Id: epub3-chunk-mods.xsl,v 1.1 2011-09-16 21:43:45 bobs Exp $ -->
+
+<xsl:include href="../xhtml5/html5-chunk-mods.xsl"/>
+
+<!--==============================================================-->
+<!--  DocBook XSL Parameter settings                              -->
+<!--==============================================================-->
+
+<!--==============================================================-->
+<!--  Template customizations                                     -->
+<!--==============================================================-->
+
+<!-- EPUB3: customize to generate package files -->
+<xsl:template match="*" mode="process.root" priority="2">
+  <xsl:apply-templates select="."/>
+  <xsl:call-template name="generate.css.files"/>
+
+  <xsl:call-template name="generate.epub.files"/>
+
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/xsl/epub3/epub3-element-mods.xsl b/xsl/epub3/epub3-element-mods.xsl
new file mode 100644 (file)
index 0000000..76966b5
--- /dev/null
@@ -0,0 +1,1654 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE xsl:stylesheet [
+<!ENTITY uppercase "'ABCDEFGHIJKLMNOPQRSTUVWXYZ'">
+<!ENTITY lowercase "'abcdefghijklmnopqrstuvwxyz'">
+]>
+
+<xsl:stylesheet 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+  xmlns:exsl="http://exslt.org/common"
+  xmlns:set="http://exslt.org/sets"
+  xmlns="http://www.w3.org/1999/xhtml"
+  xmlns:epub="http://www.idpf.org/2007/ops"
+  xmlns:m="http://www.w3.org/1998/Math/MathML"
+  xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon"
+  xmlns:ssml="http://www.w3.org/2001/10/synthesis"
+  xmlns:svg="http://www.w3.org/2000/svg"
+  xmlns:opf="http://www.idpf.org/2007/opf"
+  xmlns:dc="http://purl.org/dc/elements/1.1/"  
+  xmlns:date="http://exslt.org/dates-and-times"
+  xmlns:dcterms="http://purl.org/dc/terms/"
+  xmlns:ncx="http://www.daisy.org/z3986/2005/ncx/"
+  xmlns:db="http://docbook.org/ns/docbook"
+  xmlns:stext="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.TextFactory"
+  xmlns:str="http://exslt.org/strings"
+  xmlns:xtext="xalan://com.nwalsh.xalan.Text"
+
+  extension-element-prefixes="stext xtext"
+  exclude-result-prefixes="#default date db dc dcterms epub exsl m ncx opf pls set ssml stext str svg xtext"
+  version="1.0">
+
+<!-- $Id: epub3-element-mods.xsl,v 1.1 2011-09-16 21:43:45 bobs Exp $ -->
+
+<xsl:import href="titlepage.templates.xsl"/>
+
+<xsl:key name="image-filerefs" match="graphic|inlinegraphic|imagedata" use="@fileref"/>
+
+<!--==============================================================-->
+<!--  DocBook XSL Parameter settings                              -->
+<!--==============================================================-->
+<!-- separate file for toc -->
+<xsl:param name="chunk.tocs.and.lots" select="1"/>
+<xsl:param name="toc.section.depth" select="2"/>
+<xsl:param name="generate.toc">
+book  toc,title
+</xsl:param>
+<xsl:param name="manifest.in.base.dir" select="1"/>
+<xsl:param name="base.dir" select="'OEBPS/'"/>
+<xsl:param name="index.links.to.section" select="0"/>
+
+<!-- Turning this on crashes ADE, which is unbelievably awesome -->
+<xsl:param name="formal.object.break.after">0</xsl:param>
+
+<xsl:param name="callout.graphics" select="1"/>
+<xsl:param name="callout.graphics.extension">.png</xsl:param>
+<xsl:param name="callout.graphics.number.limit" select="15"/>
+<xsl:param name="callout.graphics.path" select="'images/callouts/'"/>
+<xsl:param name="show.comments" select="0"/>
+
+<!-- no navigation in .epub -->
+<xsl:param name="suppress.navigation" select="'1'"/> 
+
+<!-- EPUB3: use ol lists in table of contents -->
+<xsl:param name="toc.list.type">ol</xsl:param>
+<xsl:param name="autotoc.label.in.hyperlink" select="1"/>
+
+<xsl:param name="css.decoration" select="1"/>
+<!-- generate the css file from a source file -->
+<xsl:param name="make.clean.html" select="1"/>
+<!-- specify the default epub3 stylesheet -->
+<xsl:param name="docbook.css.source">docbook.css.xml</xsl:param>
+<!-- for custom CSS, use the custom.css.source param -->
+<xsl:param name="custom.css.source"></xsl:param>
+
+<!--==============================================================-->
+<!--  New EPUB3 Parameters                                        -->
+<!--==============================================================-->
+<xsl:param name="epub.version">3.0</xsl:param>
+<!-- optional ncx for backwards compatibility -->
+<xsl:param name="epub.include.ncx" select="1"/>
+<xsl:param name="epub.ncx.depth">4</xsl:param> <!-- Not functional until http://code.google.com/p/epubcheck/issues/detail?id=70 is resolved -->
+<!-- optional dcterms properties, for future compatibility -->
+<xsl:param name="epub.include.metadata.dcterms" select="1"/>
+<!-- currently required, to be replaced in future version -->
+<xsl:param name="epub.include.metadata.dc.elements" select="1"/>
+<xsl:param name="epub.autolabel" select="0"/>
+<xsl:param 
+  name="epub.vocabulary.profile.content">http://www.idpf.org/epub/30/profile/content/</xsl:param>
+<xsl:param 
+  name="epub.vocabulary.profile.package">http://www.idpf.org/epub/30/profile/package/</xsl:param>
+<xsl:param name="epub.output.epub.types" select="1"/>
+<xsl:param name="epub.oebps.dir" select="'OEBPS'"/> 
+<xsl:param name="epub.metainf.dir" select="'META-INF/'"/> 
+<xsl:param name="epub.ncx.filename" select="'toc.ncx'"/> 
+<xsl:param name="epub.mimetype.filename" select="'mimetype'"/> 
+<xsl:param name="epub.mimetype.value" select="'application/epub+zip'"/> 
+<xsl:param name="epub.container.filename" select="'container.xml'"/> 
+<xsl:param name="epub.package.filename" select="'package.opf'"/> 
+<xsl:param name="epub.cover.filename" select="concat('cover', $html.ext)"/> 
+
+<!-- names of id attributes used in package files -->
+<xsl:param name="epub.meta.identifier.id">meta-identifier</xsl:param> 
+<xsl:param name="epub.dc.identifier.id">pub-identifier</xsl:param> 
+<xsl:param name="epub.meta.title.id">meta-title</xsl:param> 
+<xsl:param name="epub.dc.title.id">pub-title</xsl:param> 
+<xsl:param name="epub.meta.language.id">meta-language</xsl:param> 
+<xsl:param name="epub.dc.language.id">pub-language</xsl:param> 
+<xsl:param name="epub.meta.creator.id">meta-creator</xsl:param> 
+<xsl:param name="epub.dc.creator.id">pub-creator</xsl:param> 
+<xsl:param name="epub.ncx.toc.id">ncxtoc</xsl:param>
+<xsl:param name="epub.ncx.manifest.id">ncx</xsl:param>
+<xsl:param name="epub.ncx.mediatype">application/x-dtbncx+xml</xsl:param>
+<xsl:param name="epub.xhtml.mediatype">application/xhtml+xml</xsl:param>
+<xsl:param name="epub.html.toc.id">htmltoc</xsl:param>
+<xsl:param name="epub.cover.filename.id" select="'cover'"/> 
+<xsl:param name="epub.cover.image.id" select="'cover-image'"/> 
+<xsl:param name="epub.cover.linear" select="0" />
+
+<xsl:param name="epub.embedded.fonts"></xsl:param>
+<xsl:param name="epub.namespace">http://www.idpf.org/2007/ops</xsl:param>
+<xsl:param name="opf.namespace">http://www.idpf.org/2007/opf</xsl:param>
+<xsl:param name="ncx.namespace">http://www.daisy.org/z3986/2005/ncx/</xsl:param>
+<xsl:param name="dc.namespace">http://purl.org/dc/elements/1.1/</xsl:param>
+<!-- prefix generated ids in package elements so they differ from content ids -->
+<xsl:param name="epub.package.id.prefix">id-</xsl:param>
+
+<!-- Generate full output path -->
+<xsl:param name="epub.package.dir" select="concat($base.dir, '../')"/>
+
+<xsl:param name="epub.ncx.pathname" 
+           select="concat($base.dir, $epub.ncx.filename)"/>
+<xsl:param name="epub.container.pathname"
+           select="concat($epub.package.dir, $epub.metainf.dir, 
+           $epub.container.filename)"/>
+<xsl:param name="epub.package.pathname"
+           select="concat($base.dir, $epub.package.filename)"/>
+<xsl:param name="epub.cover.pathname"
+           select="concat($base.dir, $epub.cover.filename)"/>
+<xsl:param name="epub.mimetype.pathname"
+           select="concat($epub.package.dir, $epub.mimetype.filename)"/>
+<!--==============================================================-->
+<!--  Template customizations                                     -->
+<!--==============================================================-->
+
+<!-- This is used only by ncx piece -->
+<xsl:variable name="root.is.a.chunk">
+  <xsl:choose>
+    <xsl:when test="/*[not(self::book)][not(sect1) or not(section)]">
+      <xsl:text>1</xsl:text>
+    </xsl:when>
+    <xsl:when test="/book[*[last()][self::bookinfo]]|book[bookinfo]">
+      <xsl:text>1</xsl:text>
+    </xsl:when>
+    <xsl:when test="/book[*[last()][self::info]]|book[info]">
+      <xsl:text>1</xsl:text>
+    </xsl:when>
+    <xsl:when test="/bibliography">
+      <xsl:text>1</xsl:text>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:text>0</xsl:text>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:variable>
+
+<!-- EPUB3: Add generation of epub publication files -->
+<xsl:template match="*" mode="process.root">
+  <xsl:variable name="doc" select="self::*"/>
+
+  <xsl:call-template name="user.preroot"/>
+  <xsl:call-template name="root.messages"/>
+
+  <html>
+    <head>
+      <xsl:call-template name="system.head.content">
+        <xsl:with-param name="node" select="$doc"/>
+      </xsl:call-template>
+      <xsl:call-template name="head.content">
+        <xsl:with-param name="node" select="$doc"/>
+      </xsl:call-template>
+      <xsl:call-template name="user.head.content">
+        <xsl:with-param name="node" select="$doc"/>
+      </xsl:call-template>
+    </head>
+    <body>
+      <xsl:call-template name="body.attributes"/>
+      <xsl:call-template name="user.header.content">
+        <xsl:with-param name="node" select="$doc"/>
+      </xsl:call-template>
+      <xsl:apply-templates select="."/>
+      <xsl:call-template name="user.footer.content">
+        <xsl:with-param name="node" select="$doc"/>
+      </xsl:call-template>
+    </body>
+  </html>
+  <xsl:value-of select="$html.append"/>
+  
+  <!-- Generate any css files only once, not once per chunk -->
+  <xsl:call-template name="generate.css.files"/>
+
+  <xsl:call-template name="generate.epub.files"/>
+
+</xsl:template>
+
+<xsl:template name="generate.epub.files">
+  <!-- Generate epub3 files -->
+  <xsl:message>
+    <xsl:text>Generating EPUB package files.</xsl:text>
+  </xsl:message>
+
+  <xsl:apply-templates select="." mode="opf"/>
+  <xsl:apply-templates select="." mode="container"/>
+  <xsl:call-template name="mimetype"/>
+  <xsl:if test="$epub.include.ncx != 0">
+    <xsl:call-template name="ncx"/>
+  </xsl:if>
+</xsl:template>
+
+<!-- Generate the package file -->
+<xsl:template match="*" mode="opf">
+
+  <xsl:variable name="lang">
+    <xsl:call-template name="l10n.language"/>
+  </xsl:variable>
+
+  <xsl:variable name="content">
+    <!-- use xsl:element so output does not have a namespace prefix -->
+    <xsl:element name="package" namespace="{$opf.namespace}">
+      <!-- Add the package namespaces at the top -->
+      <xsl:call-template name="add.package.namespaces"/>
+
+      <xsl:attribute name="version">
+        <xsl:value-of select="$epub.version"/>
+      </xsl:attribute>
+      <xsl:attribute name="xml:lang">
+        <xsl:value-of select="$lang"/>
+      </xsl:attribute>
+      <!-- No profile att in 2011-09-06 spec 
+      <xsl:attribute name="profile">
+        <xsl:value-of select="$epub.vocabulary.profile.package"/>
+      </xsl:attribute>
+      -->
+      <xsl:attribute name="unique-identifier">
+        <xsl:value-of select="$epub.dc.identifier.id"/>
+      </xsl:attribute>
+
+
+      <xsl:call-template name="package.metadata"/>
+      <xsl:call-template name="package.manifest"/>
+      <xsl:call-template name="package.spine"/>
+      <xsl:call-template name="package.guide"/>
+
+    </xsl:element>
+  </xsl:variable>
+
+  <xsl:call-template name="write.chunk">
+    <xsl:with-param name="filename">
+      <xsl:value-of select="$epub.package.pathname" />
+    </xsl:with-param>
+    <xsl:with-param name="content" select="$content"/>
+    <xsl:with-param name="method" select="'xml'" />
+    <xsl:with-param name="encoding" select="'utf-8'" />
+    <xsl:with-param name="indent" select="'yes'" />
+    <xsl:with-param name="quiet" select="$chunk.quietly" />
+    <xsl:with-param name="doctype-public" select="''"/> <!-- intentionally blank -->
+    <xsl:with-param name="doctype-system" select="''"/> <!-- intentionally blank -->
+  </xsl:call-template>
+</xsl:template>
+
+<xsl:template name="package.metadata">
+
+  <xsl:element name="metadata" namespace="{$opf.namespace}">
+
+    <xsl:call-template name="metadata.identifier"/>
+    <xsl:call-template name="metadata.title"/>
+    <xsl:call-template name="metadata.language"/>
+    <xsl:call-template name="metadata.modified"/>
+    <xsl:call-template name="metadata.other.info"/>
+    
+  </xsl:element>
+</xsl:template>
+
+<xsl:template name="doc.title">
+  <xsl:apply-templates select="." mode="title.markup"/>
+</xsl:template>
+
+<xsl:template name="metadata.identifier">
+  <xsl:variable name="package.id.value">
+    <xsl:call-template name="package-identifier"/>
+  </xsl:variable>
+
+  <xsl:if test="$epub.include.metadata.dc.elements != 0">
+    <!-- dc:identifier element -->
+    <dc:identifier>
+      <xsl:attribute name="id">
+        <xsl:value-of select="$epub.dc.identifier.id"/>
+      </xsl:attribute>
+      <!--
+      <xsl:attribute name="prefer">
+        <xsl:value-of select="$epub.meta.identifier.id"/>
+      </xsl:attribute>
+      -->
+      <xsl:copy-of select="$package.id.value"/>
+    </dc:identifier>
+  </xsl:if>
+
+  <xsl:if test="$epub.include.metadata.dcterms != 0">
+    <!-- equivalent meta identifier element -->
+    <xsl:element name="meta" namespace="{$opf.namespace}">
+      <xsl:attribute name="id">
+        <xsl:value-of select="$epub.meta.identifier.id"/>
+      </xsl:attribute>
+      <xsl:attribute name="property">dcterms:identifier</xsl:attribute>
+      <xsl:copy-of select="$package.id.value"/>
+    </xsl:element>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template name="metadata.title">
+  <xsl:variable name="doc.title">
+    <xsl:call-template name="doc.title"/>
+  </xsl:variable>
+
+  <xsl:if test="$epub.include.metadata.dc.elements != 0">
+    <dc:title>
+      <xsl:attribute name="id">
+        <xsl:value-of select="$epub.dc.title.id"/>
+      </xsl:attribute>
+      <!--
+      <xsl:attribute name="prefer">
+        <xsl:value-of select="$epub.meta.title.id"/>
+      </xsl:attribute>
+      -->
+      <xsl:value-of select="normalize-space($doc.title)"/>
+    </dc:title>
+  </xsl:if>
+
+  <xsl:if test="$epub.include.metadata.dcterms != 0">
+  <!-- equivalent meta title element -->
+    <xsl:element name="meta" namespace="{$opf.namespace}">
+      <xsl:attribute name="property">dcterms:title</xsl:attribute>
+      <xsl:attribute name="id">
+        <xsl:value-of select="$epub.meta.title.id"/>
+      </xsl:attribute>
+      <xsl:value-of select="normalize-space($doc.title)"/>
+    </xsl:element>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template name="metadata.language">
+  <xsl:variable name="lang">
+    <xsl:call-template name="l10n.language"/>
+  </xsl:variable>
+
+  <xsl:if test="$epub.include.metadata.dc.elements != 0">
+    <dc:language>
+      <xsl:attribute name="id">
+        <xsl:value-of select="$epub.dc.language.id"/>
+      </xsl:attribute>
+      <xsl:value-of select="$lang"/>
+    </dc:language>
+  </xsl:if>
+
+  <xsl:if test="$epub.include.metadata.dcterms != 0">
+  <!-- equivalent meta lang element -->
+    <xsl:element name="meta" namespace="{$opf.namespace}">
+      <xsl:attribute name="property">dcterms:language</xsl:attribute>
+      <xsl:attribute name="id">
+        <xsl:value-of select="$epub.meta.language.id"/>
+      </xsl:attribute>
+      <xsl:value-of select="$lang"/>
+    </xsl:element>
+  </xsl:if>
+</xsl:template>
+  
+<xsl:template name="metadata.modified">
+  <xsl:variable name="local.datetime" select="date:date-time()"/>
+  <xsl:variable name="utc.datetime">
+    <xsl:call-template name="convert.date.to.utc">
+      <xsl:with-param name="date" select="$local.datetime"/>
+    </xsl:call-template>
+  </xsl:variable>
+  <xsl:if test="string-length($utc.datetime) != 0">
+    <xsl:element name="meta" namespace="{$opf.namespace}">
+      <xsl:attribute name="property">dcterms:modified</xsl:attribute>
+      <xsl:value-of select="$utc.datetime"/>
+    </xsl:element>
+    <xsl:comment>The preceding date value is actually local time (not UTC) in UTC format because there is no function in XSLT 1.0 to generate a correct UTC time</xsl:comment>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template name="convert.date.to.utc">
+  <xsl:param name="date" select="''"/>
+  <!-- input format is YYYY-MM-DDTHH:MM:SS-X:00
+     where -X:00 is the offset from UTC. -->
+
+  <!-- output format is YYYY-MM-DDTHH:MM:SSZ with no offset -->
+  <!-- FIX ME:  Not so easy without a proper UTC date function. -->
+  <!-- Currently it just converts the local time to this format, which is
+       not the correct UTC time. -->
+  <xsl:value-of select="concat(substring($date,1,19), 'Z')"/>
+</xsl:template>
+
+<xsl:template name="metadata.other.info">
+  <!-- Take info relative to selected root element -->
+  <xsl:variable name="info" select="./*[contains(local-name(.), 'info')][1]"/>
+
+  <xsl:apply-templates select="$info/*" mode="opf.metadata"/>        
+</xsl:template>
+
+<xsl:template match="*" mode="opf.metadata">
+  <!-- default is no output -->
+</xsl:template>
+
+<xsl:template match="authorgroup" mode="opf.metadata">
+  <xsl:apply-templates select="author|corpauthor" mode="opf.metadata"/>
+</xsl:template>
+
+<xsl:template match="author|corpauthor" mode="opf.metadata">
+  <xsl:variable name="n">
+    <xsl:call-template name="person.name">
+      <xsl:with-param name="node" select="."/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:if test="string-length($n) != 0">
+    <dc:creator>
+      <xsl:attribute name="id">
+        <xsl:value-of select="concat($epub.dc.creator.id, position())"/>
+      </xsl:attribute>
+      <!--
+      <xsl:attribute name="prefer">
+        <xsl:value-of select="concat($epub.meta.creator.id, position())"/>
+      </xsl:attribute>
+      -->
+      <xsl:value-of select="$n"/>
+    </dc:creator>
+
+    <xsl:element name="meta" namespace="{$opf.namespace}">
+      <xsl:attribute name="id">
+        <xsl:value-of select="concat($epub.meta.creator.id, position())"/>
+      </xsl:attribute>
+      <xsl:attribute name="property">dcterms:creator</xsl:attribute>
+      <xsl:value-of select="normalize-space(string($n))"/>
+    </xsl:element>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match="date" mode="opf.metadata">
+  <xsl:element name="meta" namespace="{$opf.namespace}">
+    <xsl:attribute name="property">dcterms:date</xsl:attribute>
+    <xsl:value-of select="normalize-space(.)"/>
+  </xsl:element>
+
+</xsl:template>
+
+
+<!-- Space separate the compontents of the abstract (dropping the inline markup, sadly) -->
+<xsl:template match="abstract" mode="opf.metadata">
+  <xsl:element name="meta" namespace="{$opf.namespace}">
+    <xsl:attribute name="property">dcterms:description</xsl:attribute>
+    <xsl:for-each select="formalpara|para|simpara|title">
+      <xsl:choose>
+        <xsl:when test="self::formalpara">
+          <xsl:value-of select="normalize-space(string(title))"/>
+          <xsl:text>: </xsl:text>
+          <xsl:value-of select="normalize-space(string(para))"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:value-of select="normalize-space(string(.))"/>
+        </xsl:otherwise>  
+      </xsl:choose>
+      <xsl:if test="self::title">
+        <xsl:text>:</xsl:text>
+      </xsl:if>
+      <xsl:if test="not(position() = last())">
+        <xsl:text> </xsl:text>
+      </xsl:if>
+    </xsl:for-each>  
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="subjectset" mode="opf.metadata">
+  <xsl:apply-templates select="subject/subjectterm" mode="opf.metadata"/>
+</xsl:template>
+
+<xsl:template match="subjectterm" mode="opf.metadata">
+  <xsl:element name="meta" namespace="{$opf.namespace}">
+    <xsl:attribute name="property">dcterms:subject</xsl:attribute>
+    <xsl:value-of select="normalize-space(string(.))"/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="publisher" mode="opf.metadata">
+  <xsl:apply-templates select="publishername" mode="opf.metadata"/>
+</xsl:template>
+
+<xsl:template match="publishername" mode="opf.metadata">
+  <xsl:element name="meta" namespace="{$opf.namespace}">
+    <xsl:attribute name="property">dcterms:publisher</xsl:attribute>
+    <xsl:value-of select="normalize-space(string(.))"/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template match="copyright" mode="opf.metadata">
+  <xsl:variable name="copyright.date">
+    <xsl:call-template name="copyright.years">
+      <xsl:with-param name="years" select="year"/>
+      <xsl:with-param name="print.ranges" select="$make.year.ranges"/>
+      <xsl:with-param name="single.year.ranges" select="$make.single.year.ranges"/>
+    </xsl:call-template>
+  </xsl:variable>
+  <xsl:if test="not(../date)">
+    <xsl:element name="meta" namespace="{$opf.namespace}">
+      <xsl:attribute name="property">dcterms:date</xsl:attribute>
+      <xsl:call-template name="copyright.years">
+        <xsl:with-param name="years" select="year[last()]"/>
+        <xsl:with-param name="print.ranges" select="0"/>
+        <xsl:with-param name="single.year.ranges" select="0"/>
+      </xsl:call-template>
+    </xsl:element>
+  </xsl:if>
+  <xsl:element name="meta" namespace="{$opf.namespace}">
+    <xsl:attribute name="property">dcterms:rights</xsl:attribute>
+    <xsl:call-template name="gentext">
+      <xsl:with-param name="key" select="'Copyright'"/>
+    </xsl:call-template>
+    <xsl:call-template name="gentext.space"/>
+    <xsl:text>&#x00A9;</xsl:text>
+    <xsl:call-template name="gentext.space"/>
+    <xsl:value-of select="$copyright.date"/>
+    <xsl:call-template name="gentext.space"/>
+    <xsl:apply-templates select="holder" mode="titlepage.mode"/>
+  </xsl:element>
+  <xsl:element name="meta" namespace="{$opf.namespace}">
+    <xsl:attribute name="property">dcterms:rightsHolder</xsl:attribute>
+    <xsl:apply-templates select="holder" mode="titlepage.mode"/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template name="package.guide"/>
+
+<xsl:template name="package-identifier">  
+
+  <xsl:variable name="info" select="./*[contains(local-name(.), 'info')][1]"/>
+
+  <xsl:choose>
+    <xsl:when test="$info/biblioid">
+      <xsl:if test="$info/biblioid[1][@class = 'doi' or 
+                                      @class = 'isbn' or
+                                      @class = 'isrn' or
+                                      @class = 'istc' or
+                                      @class = 'issn']">
+        <xsl:text>urn:</xsl:text>
+        <xsl:value-of select="$info/biblioid[1]/@class"/>
+        <xsl:text>:</xsl:text>
+      </xsl:if>
+      <xsl:value-of select="normalize-space($info/biblioid[1])"/>
+    </xsl:when>
+    <xsl:when test="$info/isbn">
+      <xsl:text>urn:isbn:</xsl:text>
+      <xsl:value-of select="$info/isbn[1]"/>
+    </xsl:when>
+    <xsl:when test="$info/issn">
+      <xsl:text>urn:issn:</xsl:text>
+      <xsl:value-of select="$info/issn[1]"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:choose>
+        <xsl:when test="$info/invpartnumber">
+          <xsl:value-of select="$info/invpartnumber[1]"/>
+        </xsl:when>
+        <xsl:when test="$info/issuenum">
+          <xsl:value-of select="$info/issuenum[1]"/>
+        </xsl:when>
+        <xsl:when test="$info/productnumber">
+          <xsl:value-of select="$info/productnumber[1]"/>
+        </xsl:when>
+        <xsl:when test="$info/seriesvolnums">
+          <xsl:value-of select="$info/seriesvolnums[1]"/>
+        </xsl:when>
+        <xsl:when test="$info/volumenum">
+          <xsl:value-of select="$info/volumenum[1]"/>
+        </xsl:when>
+        <!-- Deprecated -->
+        <xsl:when test="$info/pubsnumber">
+          <xsl:value-of select="$info/pubsnumber[1]"/>
+        </xsl:when>
+      </xsl:choose>  
+      <xsl:text>_</xsl:text>
+      <xsl:choose>
+        <xsl:when test="@id">
+          <xsl:value-of select="@id"/>
+        </xsl:when>
+        <xsl:when test="@xml:id">
+          <xsl:value-of select="@xml:id"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <!-- TODO: Do UUIDs here -->
+          <xsl:value-of select="generate-id(.)"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- EPUB3: add epub:type attribute where appropriate -->
+<xsl:template match="*" mode="common.html.attributes">
+  <xsl:param name="class" select="local-name(.)"/>
+  <xsl:param name="inherit" select="0"/>
+  <xsl:call-template name="generate.html.lang"/>
+  <xsl:call-template name="dir">
+    <xsl:with-param name="inherit" select="$inherit"/>
+  </xsl:call-template>
+  <xsl:apply-templates select="." mode="class.attribute">
+    <xsl:with-param name="class" select="$class"/>
+  </xsl:apply-templates>
+  <xsl:call-template name="generate.html.title"/>
+  <xsl:apply-templates select="." mode="epub.type"/>
+</xsl:template>
+
+<xsl:template match="*" mode="epub.type" priority="-1"/>
+
+<xsl:template match="chapter
+                    |section
+                    |appendix
+                    |epigraph
+                    |warning
+                    |preface
+                    |index
+                    |colophon
+                    |glossary
+                    |biblioentry
+                    |bibliography
+                    |dedication
+                    |sidebar
+                    |footnote
+                    |bridgehead
+                    |part" mode="epub.type">
+  <xsl:variable name="type" select="local-name()"/>
+
+  <xsl:if test="$epub.output.epub.types != 0">
+    <xsl:attribute name="epub:type">
+      <xsl:value-of select="$type"/>
+    </xsl:attribute>
+  </xsl:if>
+</xsl:template>
+
+<!-- EPUB3: to add attributes to root output element -->
+<xsl:template name="root.attributes">
+  <!-- collect and output all namespace declarations -->
+  <xsl:call-template name="all.namespaces"/>
+</xsl:template>
+
+<xsl:template name="all.namespaces">
+  <!-- add the epub3 namespaces to the top output element -->
+  <xsl:variable name="temp">
+    <epub:foo/>
+    <m:foo/>
+    <pls:foo/>
+    <ssml:foo/>
+    <svg:foo/>
+  </xsl:variable>
+
+  <xsl:variable name="nodes" select="exsl:node-set($temp)"/>
+  <xsl:for-each select="$nodes//*/namespace::*">
+    <xsl:copy-of select="."/>
+  </xsl:for-each>
+
+</xsl:template>
+
+<xsl:template name="add.package.namespaces">
+  <!-- add the epub3 package namespaces to the top output element -->
+  <xsl:variable name="temp">
+    <dc:foo/>
+    <dcterms:foo/>
+  </xsl:variable>
+
+  <xsl:variable name="nodes" select="exsl:node-set($temp)"/>
+  <xsl:for-each select="$nodes//*[local-name(.) ='foo']/namespace::*">
+    <xsl:if test="contains(., 'purl.org')">
+      <xsl:copy-of select="."/>
+    </xsl:if>
+  </xsl:for-each>
+
+</xsl:template>
+
+
+<xsl:template name="footnotes.attributes">
+  <xsl:if test="$epub.output.epub.types != 0">
+    <xsl:attribute name="epub:type">footnotes</xsl:attribute>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template name="package.manifest">
+  <xsl:element name="manifest" namespace="{$opf.namespace}">
+    <xsl:if test="$epub.include.ncx != 0">
+      <xsl:call-template name="manifest.ncx"/>
+    </xsl:if>
+    <xsl:call-template name="manifest.fonts"/>
+    <xsl:call-template name="manifest.toc"/>
+    <xsl:call-template name="manifest.css"/>
+    <xsl:call-template name="manifest.cover"/>
+    <xsl:call-template name="manifest.content.items"/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template name="manifest.css">
+  <xsl:if test="$html.stylesheet != ''">
+    <xsl:element namespace="{$opf.namespace}" name="item">
+      <xsl:attribute name="media-type">text/css</xsl:attribute>
+      <xsl:attribute name="id">html-css</xsl:attribute>
+      <xsl:attribute name="href">
+        <xsl:value-of select="$html.stylesheet"/>
+      </xsl:attribute>
+    </xsl:element>
+  </xsl:if>
+  <xsl:if test="string-length($docbook.css.source) != 0">
+    <xsl:variable name="dfilename">
+      <xsl:call-template name="css.output.filename">
+        <xsl:with-param name="src" select="$docbook.css.source"/>
+      </xsl:call-template>
+    </xsl:variable>
+    <xsl:element namespace="{$opf.namespace}" name="item">
+      <xsl:attribute name="media-type">text/css</xsl:attribute>
+      <xsl:attribute name="id">docbook-css</xsl:attribute>
+      <xsl:attribute name="href">
+        <xsl:value-of select="$dfilename"/>
+      </xsl:attribute>
+    </xsl:element>
+  </xsl:if>
+  <xsl:if test="string-length($custom.css.source) != 0">
+    <xsl:variable name="cfilename">
+      <xsl:call-template name="css.output.filename">
+        <xsl:with-param name="src" select="$custom.css.source"/>
+      </xsl:call-template>
+    </xsl:variable>
+    <xsl:element namespace="{$opf.namespace}" name="item">
+      <xsl:attribute name="media-type">text/css</xsl:attribute>
+      <xsl:attribute name="id">custom-css</xsl:attribute>
+      <xsl:attribute name="href">
+        <xsl:value-of select="$cfilename"/>
+      </xsl:attribute>
+    </xsl:element>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template name="manifest.ncx">
+  <xsl:element name="item" namespace="{$opf.namespace}">
+    <xsl:attribute name="id">
+      <xsl:value-of select="$epub.ncx.manifest.id"/>
+    </xsl:attribute>
+    <xsl:attribute name="href">
+      <xsl:value-of select="$epub.ncx.filename"/>
+    </xsl:attribute>
+    <xsl:attribute name="media-type">
+      <xsl:value-of select="$epub.ncx.mediatype"/>
+    </xsl:attribute>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template name="manifest.fonts"/>
+<xsl:template name="manifest.other.items"/>
+
+<xsl:template name="manifest.cover">
+  <xsl:variable name="info" select="./*[contains(local-name(.), 'info')][1]"/>
+  <xsl:variable name="cover.image" 
+                select="$info//mediaobject[@role='cover' or ancestor::cover]"/>
+
+  <xsl:if test="$cover.image">
+
+    <!-- generate the manifest link to that page -->
+    <xsl:variable name="olist" select="$cover.image/imageobject|$cover.image/imageobjectco
+                       |$cover.image/videoobject|$cover.image/audioobject
+                       |$cover.image/textobject"/>
+  
+    <xsl:variable name="object.index">
+      <xsl:call-template name="select.mediaobject.index">
+        <xsl:with-param name="olist" select="$olist"/>
+        <xsl:with-param name="count" select="1"/>
+      </xsl:call-template>
+    </xsl:variable>
+  
+    <xsl:variable name="object" select="$olist[position() = $object.index]"/>
+
+    <xsl:variable name="image.filename">
+      <xsl:call-template name="mediaobject.filename">
+        <xsl:with-param name="object" select="$object"/>
+      </xsl:call-template>
+    </xsl:variable>
+
+    <xsl:variable name="image.extension">
+      <xsl:call-template name="filename-extension">
+        <xsl:with-param name="filename" select="$image.filename"/>
+      </xsl:call-template>
+    </xsl:variable>
+
+    <xsl:variable name="image.type">
+      <xsl:call-template name="graphic.format.content-type">
+        <xsl:with-param name="format" select="translate($image.extension, 
+                   &lowercase;, &uppercase;)"/>
+      </xsl:call-template>
+    </xsl:variable>
+
+    <!-- Reference to cover html file -->
+    <xsl:element namespace="{$opf.namespace}" name="item">
+      <xsl:attribute name="id">
+        <xsl:value-of select="$epub.cover.filename.id"/>
+      </xsl:attribute>
+      <xsl:attribute name="href">
+        <xsl:value-of select="$epub.cover.filename"/>
+      </xsl:attribute>
+      <xsl:attribute name="media-type">
+        <xsl:value-of select="$epub.xhtml.mediatype"/>
+      </xsl:attribute>
+    </xsl:element>
+
+    <!-- special item with property="cover-image" -->
+    <xsl:element namespace="{$opf.namespace}" name="item">
+      <xsl:attribute name="id">
+        <xsl:value-of select="$epub.cover.image.id"/>
+      </xsl:attribute>
+      <xsl:attribute name="properties">cover-image</xsl:attribute>
+      <xsl:attribute name="href">
+        <xsl:value-of select="$image.filename"/>
+      </xsl:attribute>
+      <xsl:if test="$image.type">
+        <xsl:attribute name="media-type">
+          <xsl:value-of select="$image.type"/>
+        </xsl:attribute>
+      </xsl:if>
+    </xsl:element>
+
+    <!-- And generate the cover html file -->
+    <xsl:apply-templates select="$cover.image"/>
+
+  </xsl:if>
+</xsl:template>
+
+<xsl:template name="graphic.format.content-type">
+  <xsl:param name="format" select="''"/>
+  <xsl:choose>
+    <xsl:when test="$format = ''"></xsl:when>
+    <xsl:when test="$format = 'linespecific'"></xsl:when>
+    <xsl:when test="$format = 'PS'">application/postscript</xsl:when>
+    <xsl:when test="$format = 'PDF'">application/pdf</xsl:when>
+    <xsl:when test="$format = 'PNG'">image/png</xsl:when>
+    <xsl:when test="$format = 'SVG'">image/svg+xml</xsl:when>
+    <xsl:when test="$format = 'JPG'">image/jpeg</xsl:when>
+    <xsl:when test="$format = 'GIF87a'">image/gif</xsl:when>
+    <xsl:when test="$format = 'GIF89a'">image/gif</xsl:when>
+    <xsl:otherwise>
+        <xsl:value-of select="concat('image/', 
+          translate($format, &uppercase;, &lowercase;))"/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template name="manifest.toc">
+  <xsl:variable name="toc.params">
+    <xsl:call-template name="find.path.params">
+      <xsl:with-param name="node" select="."/>
+      <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:if test="contains($toc.params, 'toc')">
+    <xsl:element namespace="{$opf.namespace}" name="item">
+      <xsl:attribute name="id">
+        <xsl:value-of select="$epub.html.toc.id"/>
+      </xsl:attribute>
+      <xsl:attribute name="properties">nav</xsl:attribute>
+      <xsl:attribute name="media-type">
+        <xsl:value-of select="$epub.xhtml.mediatype"/>
+      </xsl:attribute>
+      <xsl:attribute name="href">
+        <xsl:call-template name="toc-href">
+          <xsl:with-param name="node" select="."/>
+        </xsl:call-template>
+      </xsl:attribute>
+    </xsl:element>
+  </xsl:if>  
+</xsl:template>
+
+<xsl:template name="toc-href">
+  <xsl:param name="node" select="."/>
+  <!-- FIXME -->
+  <xsl:apply-templates select="$node" 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:template>
+
+<xsl:template match="*" mode="recursive-chunk-filename">
+  <!-- placeholder for real template in chunking stylesheet -->
+  <xsl:value-of select="concat(local-name(.), '-', generate-id(.))"/>
+</xsl:template>
+
+<xsl:template name="manifest.content.items">
+  <xsl:apply-templates select="." mode="package.manifest"/>
+  <xsl:call-template name="manifest.images"/>
+</xsl:template>
+
+<xsl:template match="text()" mode="package.manifest"/>
+
+<xsl:template match="mediaobject|mediaobjectco|inlinemediaobject" priority="1"
+              mode="package.manifest">
+  <!-- These are handled out of line so a unique list is created
+       to remove duplicate references -->
+</xsl:template>
+
+<xsl:template match="*" mode="package.manifest">
+
+  <xsl:variable name="is.chunk">
+    <xsl:call-template name="chunk">
+      <xsl:with-param name="node" select="."/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:if test="$is.chunk != 0">
+    <xsl:variable name="href">
+      <xsl:call-template name="href.target.with.base.dir">
+        <xsl:with-param name="context" select="/"/>
+      </xsl:call-template>
+    </xsl:variable>
+  
+    <xsl:variable name="id" select="concat($epub.package.id.prefix, generate-id())"/>
+
+    <xsl:element namespace="{$opf.namespace}" name="item">
+      <xsl:attribute name="id">
+        <xsl:value-of select="$id"/>
+      </xsl:attribute>
+      <xsl:attribute name="href">
+        <xsl:value-of select="$href"/>
+      </xsl:attribute>
+      <xsl:attribute name="media-type">application/xhtml+xml</xsl:attribute>
+    </xsl:element>
+  </xsl:if>  
+  <xsl:apply-templates mode="package.manifest"/>
+
+</xsl:template>
+
+<xsl:template name="manifest.image.item">
+</xsl:template>
+
+<!-- Need a uniqued list of images -->
+<xsl:template name="manifest.images">
+  <xsl:message>Generating image list ...</xsl:message>
+  <xsl:variable name="imagelist">
+    <xsl:choose>
+      <xsl:when test="$rootid != ''">
+        <xsl:apply-templates select="key('id', $rootid)" mode="enumerate-images"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:apply-templates select="/" mode="enumerate-images"/>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
+  <xsl:choose>
+    <xsl:when test="$exsl.node.set.available != 0 and 
+                    function-available('set:distinct')">
+      <xsl:for-each select="set:distinct(exsl:node-set($imagelist)/*)">
+        <xsl:if test="string-length(href) != 0">
+          <xsl:element name="item" namespace="{$opf.namespace}">
+            <xsl:attribute name="id">
+              <xsl:value-of select="generate-id()"/>
+            </xsl:attribute>
+            <xsl:attribute name="href">
+              <xsl:value-of select="href"/>
+            </xsl:attribute>
+            <xsl:attribute name="media-type">
+              <xsl:value-of select="media-type"/>
+            </xsl:attribute>
+          </xsl:element>
+        </xsl:if>
+      </xsl:for-each>
+    </xsl:when>
+    <xsl:when test="$exsl.node.set.available != 0">
+      <xsl:for-each select="exsl:node-set($imagelist)/*">
+        <xsl:element name="item" namespace="{$opf.namespace}">
+          <xsl:attribute name="id">
+            <xsl:value-of select="generate-id()"/>
+          </xsl:attribute>
+          <xsl:copy-of select="@*"/>
+        </xsl:element>
+      </xsl:for-each>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:message terminate="yes">
+        <xsl:text>ERROR: cannot process images list without </xsl:text>
+        <xsl:text>exsl:node-set() function</xsl:text>
+      </xsl:message>
+      <!-- cannot do this without node-set() -->
+    </xsl:otherwise>
+  </xsl:choose>
+
+</xsl:template>
+
+<xsl:template match="*" mode="enumerate-images">
+  <xsl:apply-templates mode="enumerate-images"/>
+</xsl:template>
+
+<xsl:template match="text()" mode="enumerate-images"/>
+
+<xsl:template match="graphic|inlinegraphic[@format!='linespecific']" 
+              mode="enumerate-images">
+</xsl:template>
+
+<!-- cover image handled separates to give it an extra property attribute -->
+<xsl:template match="mediaobject[@role='cover' or ancestor::cover]"
+              mode="enumerate-images"/>
+
+<xsl:template match="mediaobject|inlinemediaobject" mode="enumerate-images">
+
+  <xsl:variable name="olist" select="imageobject|imageobjectco|
+                     videoobject|audioobject|
+                     textobject"/>
+  <xsl:variable name="object.index">
+    <xsl:call-template name="select.mediaobject.index">
+      <xsl:with-param name="olist" select="$olist"/>
+      <xsl:with-param name="count" select="1"/>
+    </xsl:call-template>
+  </xsl:variable>
+  
+  <xsl:variable name="object" select="$olist[position() = $object.index]"/>
+
+  <xsl:if test="$object">
+    <xsl:variable name="image.filename">
+      <xsl:call-template name="mediaobject.filename">
+        <xsl:with-param name="object" select="$object"/>
+      </xsl:call-template>
+    </xsl:variable>
+
+    <xsl:variable name="image.extension">
+      <xsl:call-template name="filename-extension">
+        <xsl:with-param name="filename" select="$image.filename"/>
+      </xsl:call-template>
+    </xsl:variable>
+
+    <xsl:variable name="image.type">
+      <xsl:call-template name="graphic.format.content-type">
+        <xsl:with-param name="format" select="translate($image.extension, 
+                   &lowercase;, &uppercase;)"/>
+      </xsl:call-template>
+    </xsl:variable>
+
+    <xsl:element name="filename" namespace="">
+      <xsl:element name="href" namespace="">
+        <xsl:value-of select="$image.filename"/>
+      </xsl:element>
+      <xsl:element name="media-type" namespace="">
+        <xsl:value-of select="$image.type"/>
+      </xsl:element>
+    </xsl:element>
+
+  </xsl:if>
+</xsl:template>
+
+<!-- ======================================================== -->
+<!-- NCX templates are for backwards compatibility with EPUB2 -->
+<!-- ======================================================== -->
+
+<xsl:template name="ncx">
+  <xsl:message>Generating NCX file ...</xsl:message>
+  <xsl:call-template name="write.chunk">
+    <xsl:with-param name="filename">
+      <xsl:value-of select="$epub.ncx.pathname" />
+    </xsl:with-param>
+    <xsl:with-param name="method" select="'xml'" />
+    <xsl:with-param name="encoding" select="'utf-8'" />
+    <xsl:with-param name="indent" select="'no'" />
+    <xsl:with-param name="quiet" select="$chunk.quietly" />
+    <xsl:with-param name="doctype-public" select="''"/> <!-- intentionally blank -->
+    <xsl:with-param name="doctype-system" select="''"/> <!-- intentionally blank -->
+    <xsl:with-param name="content">
+      <xsl:element name="ncx" namespace="{$ncx.namespace}">
+        <xsl:attribute name="version">2005-1</xsl:attribute>
+
+          <!-- Via Martin Goerner: On covers: the IDPF2.0 standard unfortunately does not have a provision for
+          covers. We had to add one and we did so in conjunction with the IDPF and
+          various publishers. The tag chosen to define the covers is:
+          <meta name="cover" content="-reference to a manifest item-">
+          Then, we also added a bit of logic to get rid cleanly of the HTML cover
+          people usually add because the logical cover is not specced by the IDPF. So,
+          if the HTML cover item is marked linear="no" AND there is a guide item of
+          type="cover" pointing to it AND there is a logical cover specified in a
+          <meta name="cover"> tag, THEN, the HTML cover is discarded. -->
+        <xsl:element name="head" namespace="{$ncx.namespace}">
+          <xsl:if test="/*/*[cover or contains(name(.), 'info')]//mediaobject[@role='cover' or ancestor::cover]"> 
+            <xsl:element name="meta" namespace="{$ncx.namespace}">
+              <xsl:attribute name="name">cover</xsl:attribute>
+              <xsl:attribute name="content">
+                <xsl:value-of select="$epub.cover.filename.id"/>
+              </xsl:attribute>
+            </xsl:element>
+          </xsl:if>
+          <xsl:element name="meta" namespace="{$ncx.namespace}">
+            <xsl:attribute name="name">dtb:uid</xsl:attribute>
+            <xsl:attribute name="content"><xsl:call-template name="package-identifier"/></xsl:attribute>
+          </xsl:element>
+        </xsl:element>
+
+        <xsl:choose>
+          <xsl:when test="$rootid != ''">
+            <xsl:variable name="title">
+              <xsl:if test="$epub.autolabel != 0">
+                <xsl:variable name="label.markup">
+                  <xsl:apply-templates select="key('id',$rootid)" mode="label.markup" />
+                </xsl:variable>
+                <xsl:if test="normalize-space($label.markup)">
+                  <xsl:value-of select="concat($label.markup,$autotoc.label.separator)" />
+                </xsl:if>
+              </xsl:if>
+              <xsl:apply-templates select="key('id',$rootid)" mode="title.markup" />
+            </xsl:variable>
+            <xsl:variable name="href">
+              <xsl:call-template name="href.target.with.base.dir">
+                <xsl:with-param name="object" select="key('id',$rootid)" />
+              </xsl:call-template>
+            </xsl:variable>
+            <xsl:element name="docTitle" namespace="{$ncx.namespace}">
+              <xsl:element name="text" namespace="{$ncx.namespace}"><xsl:value-of select="normalize-space($title)" />  </xsl:element>
+            </xsl:element>
+            <xsl:element name="navMap" namespace="{$ncx.namespace}">
+              <xsl:apply-templates select="key('id',$rootid)/*" mode="ncx" />
+            </xsl:element>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:variable name="title">
+              <xsl:if test="$epub.autolabel != 0">
+                <xsl:variable name="label.markup">
+                  <xsl:apply-templates select="/*" mode="label.markup" />
+                </xsl:variable>
+                <xsl:if test="normalize-space($label.markup)">
+                  <xsl:value-of select="concat($label.markup,$autotoc.label.separator)" />
+                </xsl:if>
+              </xsl:if>
+              <xsl:apply-templates select="/*" mode="title.markup" />
+            </xsl:variable>
+            <xsl:variable name="href">
+              <xsl:call-template name="href.target.with.base.dir">
+                <xsl:with-param name="object" select="/" />
+              </xsl:call-template>
+            </xsl:variable>
+            <xsl:element name="docTitle" namespace="{$ncx.namespace}">
+              <xsl:element name="text" namespace="{$ncx.namespace}">
+                <xsl:value-of select="normalize-space($title)" />
+              </xsl:element>
+            </xsl:element>
+            <xsl:element name="navMap" namespace="{$ncx.namespace}">
+              <xsl:choose>
+                <xsl:when test="$root.is.a.chunk != '0'">
+                  <xsl:apply-templates select="/*" mode="ncx" />
+                </xsl:when>
+                <xsl:otherwise>
+                  <xsl:apply-templates select="/*/*" mode="ncx" />
+                </xsl:otherwise>
+              </xsl:choose>
+            </xsl:element>
+          </xsl:otherwise>
+
+        </xsl:choose>
+      </xsl:element>
+    </xsl:with-param>
+  </xsl:call-template>
+</xsl:template>
+
+<xsl:template match="book|
+                     article|
+                     part|
+                     reference|
+                     preface|
+                     chapter|
+                     bibliography|
+                     appendix|
+                     glossary|
+                     section|
+                     sect1|
+                     sect2|
+                     sect3|
+                     sect4|
+                     sect5|
+                     refentry|
+                     colophon|
+                     bibliodiv[title]|
+                     setindex|
+                     index"
+              mode="ncx">
+  <xsl:variable name="depth" select="count(ancestor::*)"/>
+  <xsl:variable name="title">
+    <xsl:if test="$epub.autolabel != 0">
+      <xsl:variable name="label.markup">
+        <xsl:apply-templates select="." mode="label.markup" />
+      </xsl:variable>
+      <xsl:if test="normalize-space($label.markup)">
+        <xsl:value-of
+          select="concat($label.markup,$autotoc.label.separator)" />
+      </xsl:if>
+    </xsl:if>
+    <xsl:apply-templates select="." mode="title.markup" />
+  </xsl:variable>
+
+  <xsl:variable name="href">
+    <xsl:call-template name="href.target.with.base.dir">
+      <xsl:with-param name="context" select="/" />
+      <!-- Generate links relative to the location of root file/toc.xml file -->
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:variable name="id">
+    <xsl:value-of select="generate-id(.)"/>
+  </xsl:variable>
+  <xsl:variable name="order">
+    <xsl:value-of select="$depth +
+                                count(preceding::part|
+                                preceding::reference|
+                                preceding::book[parent::set]|
+                                preceding::preface|
+                                preceding::chapter|
+                                preceding::bibliography|
+                                preceding::appendix|
+                                preceding::article|
+                                preceding::glossary|
+                                preceding::section[not(parent::partintro)]|
+                                preceding::sect1[not(parent::partintro)]|
+                                preceding::sect2[not(ancestor::partintro)]|
+                                preceding::sect3[not(ancestor::partintro)]|
+                                preceding::sect4[not(ancestor::partintro)]|
+                                preceding::sect5[not(ancestor::partintro)]|
+                                preceding::refentry|
+                                preceding::colophon|
+                                preceding::bibliodiv[title]|
+                                preceding::index)"/>
+  </xsl:variable>
+
+  <xsl:element name="navPoint" namespace="{$ncx.namespace}">
+    <xsl:attribute name="id">
+      <xsl:value-of select="$id"/>
+    </xsl:attribute>
+
+    <xsl:attribute name="playOrder">
+      <xsl:choose>
+        <xsl:when test="/*[self::set]">
+          <xsl:value-of select="$order"/>
+        </xsl:when>
+        <xsl:when test="$root.is.a.chunk != '0'">
+          <xsl:value-of select="$order + 1"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:value-of select="$order - 0"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:attribute>
+    <xsl:element name="navLabel" namespace="{$ncx.namespace}">
+      <xsl:element name="text" namespace="{$ncx.namespace}"><xsl:value-of select="normalize-space($title)"/> </xsl:element>
+    </xsl:element>
+    <xsl:element name="content" namespace="{$ncx.namespace}">
+      <xsl:attribute name="src">
+        <xsl:value-of select="$href"/>
+      </xsl:attribute>
+    </xsl:element>
+    <xsl:apply-templates select="book[parent::set]|part|reference|preface|chapter|bibliography|appendix|article|glossary|section|sect1|sect2|sect3|sect4|sect5|refentry|colophon|bibliodiv[title]|setindex|index" mode="ncx"/>
+  </xsl:element>
+
+</xsl:template>
+
+<xsl:template match="text()" mode="ncx" />
+
+<xsl:template name="package.spine">
+
+  <xsl:variable name="toc.params">
+    <xsl:call-template name="find.path.params">
+      <xsl:with-param name="node" select="."/>
+      <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:element namespace="http://www.idpf.org/2007/opf" name="spine">
+    <xsl:if test="$epub.include.ncx != 0">
+      <xsl:attribute name="toc">
+        <xsl:value-of select="$epub.ncx.manifest.id"/>
+      </xsl:attribute>
+    </xsl:if>
+
+    <xsl:call-template name="spine.cover"/>
+
+
+    <xsl:if test="contains($toc.params, 'toc')">
+      <xsl:element namespace="http://www.idpf.org/2007/opf" name="itemref">
+        <xsl:attribute name="idref"> <xsl:value-of select="$epub.html.toc.id"/> </xsl:attribute>
+        <xsl:attribute name="linear">yes</xsl:attribute>
+      </xsl:element>
+    </xsl:if>  
+
+    <!-- TODO: be nice to have a idref="titlepage" here -->
+    <xsl:choose>
+      <xsl:when test="$root.is.a.chunk != '0'">
+        <xsl:apply-templates select="/*" mode="package.spine"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:apply-templates select="/*/*" mode="package.spine"/>
+      </xsl:otherwise>
+    </xsl:choose>
+                                 
+  </xsl:element>
+</xsl:template>
+
+<xsl:template name="spine.cover">
+  <xsl:variable name="info" select="./*[contains(local-name(.), 'info')][1]"/>
+  <xsl:variable name="cover.image" 
+                select="$info//mediaobject[@role='cover' or ancestor::cover]"/>
+
+  <xsl:if test="$cover.image">
+    <!-- generate the spine reference to that cover html file -->
+    <xsl:element namespace="http://www.idpf.org/2007/opf" name="itemref">
+      <xsl:attribute name="idref">
+        <xsl:value-of select="$epub.cover.filename.id"/>
+      </xsl:attribute>
+      <xsl:attribute name="linear">
+      <xsl:choose>
+        <xsl:when test="$epub.cover.linear">
+          <xsl:text>yes</xsl:text>
+        </xsl:when>
+        <xsl:otherwise>no</xsl:otherwise>
+      </xsl:choose>
+      </xsl:attribute>
+    </xsl:element>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match="*" mode="package.spine">
+  <xsl:variable name="is.chunk">
+    <xsl:call-template name="chunk">
+      <xsl:with-param name="node" select="."/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:if test="$is.chunk != 0">
+    <xsl:element namespace="http://www.idpf.org/2007/opf" name="itemref">
+      <xsl:attribute name="idref">
+        <xsl:value-of select="concat($epub.package.id.prefix, generate-id(.))"/>
+      </xsl:attribute>
+    </xsl:element>
+    <xsl:apply-templates select="*|.//refentry" mode="package.spine"/>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match="*" mode="container">
+  <xsl:call-template name="container"/>
+</xsl:template>
+
+<xsl:template name="container">
+  <xsl:call-template name="write.chunk">
+    <xsl:with-param name="filename">
+      <xsl:value-of select="$epub.container.pathname" />
+    </xsl:with-param>
+    <xsl:with-param name="method" select="'xml'" />
+    <xsl:with-param name="encoding" select="'utf-8'" />
+    <xsl:with-param name="indent" select="'no'" />
+    <xsl:with-param name="quiet" select="$chunk.quietly" />
+    <xsl:with-param name="doctype-public" select="''"/> <!-- intentionally blank -->
+    <xsl:with-param name="doctype-system" select="''"/> <!-- intentionally blank -->
+
+    <xsl:with-param name="content">
+      <xsl:element namespace="urn:oasis:names:tc:opendocument:xmlns:container" name="container">
+        <xsl:attribute name="version">1.0</xsl:attribute>
+        <xsl:element namespace="urn:oasis:names:tc:opendocument:xmlns:container" name="rootfiles">
+          <xsl:element namespace="urn:oasis:names:tc:opendocument:xmlns:container" name="rootfile">
+            <xsl:attribute name="full-path">
+              <xsl:value-of 
+                     select="concat($epub.oebps.dir, '/', $epub.package.filename)"/>
+            </xsl:attribute>
+            <xsl:attribute name="media-type">
+              <xsl:text>application/oebps-package+xml</xsl:text>
+            </xsl:attribute>
+          </xsl:element>
+        </xsl:element>
+      </xsl:element>
+    </xsl:with-param>
+  </xsl:call-template>
+</xsl:template>
+
+<xsl:template name="mimetype">'
+  <xsl:call-template name="write.text.chunk">
+    <xsl:with-param name="filename" select="$epub.mimetype.pathname"/>
+    <xsl:with-param name="content" select="$epub.mimetype.value"/>
+  </xsl:call-template>
+</xsl:template>
+
+<xsl:template match="mediaobject[@role='cover' or ancestor::cover]">
+  <xsl:call-template name="write.chunk">
+    <xsl:with-param name="filename">
+      <xsl:value-of select="$epub.cover.pathname" />
+    </xsl:with-param>
+    <xsl:with-param name="method" select="'xml'" />
+    <xsl:with-param name="encoding" select="'utf-8'" />
+    <xsl:with-param name="indent" select="'no'" />
+    <xsl:with-param name="quiet" select="$chunk.quietly" />
+    <xsl:with-param name="content">
+      <xsl:element namespace="http://www.w3.org/1999/xhtml" name="html">
+        <xsl:element namespace="http://www.w3.org/1999/xhtml" name="head">
+          <xsl:element namespace="http://www.w3.org/1999/xhtml" name="title">Cover</xsl:element>
+          <xsl:element namespace="http://www.w3.org/1999/xhtml" name="style">
+            <xsl:attribute name="type">text/css</xsl:attribute>
+            <!-- Help the cover image scale nicely in the CSS then apply a max-width to look better in Adobe Digital Editions -->
+            <xsl:text> img { max-width: 100%; }</xsl:text>
+          </xsl:element>
+        </xsl:element>
+        <xsl:element namespace="http://www.w3.org/1999/xhtml" name="body">
+          <xsl:element namespace="http://www.w3.org/1999/xhtml" name="div">
+            <xsl:attribute name="id">
+              <xsl:value-of select="$epub.cover.image.id"/>
+            </xsl:attribute>
+            <xsl:choose>
+              <xsl:when test="imageobject[@role='front-large']">
+                <xsl:apply-templates select="imageobject[@role='front-large']"/>
+              </xsl:when>
+              <xsl:otherwise>
+                <xsl:apply-templates select="imageobject[1]"/>
+              </xsl:otherwise>
+            </xsl:choose>
+          </xsl:element>
+          <!-- If this is defined as an explicit cover page, then process
+          any remaining text -->
+          <xsl:if test="ancestor::cover">
+            <xsl:apply-templates select="ancestor::cover/para"/>
+          </xsl:if>
+        </xsl:element>
+      </xsl:element>
+    </xsl:with-param>  
+  </xsl:call-template>  
+</xsl:template>
+
+<!-- EPUB3: use <nav> and <ol> in TOC lists  -->
+<xsl:template name="make.toc">
+  <xsl:param name="toc-context" select="."/>
+  <xsl:param name="toc.title.p" select="true()"/>
+  <xsl:param name="nodes" select="/NOT-AN-ELEMENT"/>
+
+  <xsl:variable name="nodes.plus" select="$nodes | qandaset"/>
+
+  <xsl:variable name="toc.title">
+    <xsl:if test="$toc.title.p">
+      <xsl:choose>
+        <xsl:when test="$make.clean.html != 0">
+          <div class="toc-title">
+            <xsl:call-template name="gentext">
+              <xsl:with-param name="key">TableofContents</xsl:with-param>
+            </xsl:call-template>
+          </div>
+        </xsl:when>
+        <xsl:otherwise>
+          <p>
+            <b>
+              <xsl:call-template name="gentext">
+                <xsl:with-param name="key">TableofContents</xsl:with-param>
+              </xsl:call-template>
+            </b>
+          </p>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:if>
+  </xsl:variable>
+
+  <xsl:choose>
+    <xsl:when test="$manual.toc != ''">
+      <xsl:variable name="id">
+        <xsl:call-template name="object.id"/>
+      </xsl:variable>
+      <xsl:variable name="toc" select="document($manual.toc, .)"/>
+      <xsl:variable name="tocentry" select="$toc//tocentry[@linkend=$id]"/>
+      <xsl:if test="$tocentry and $tocentry/*">
+        <div class="toc">
+          <xsl:copy-of select="$toc.title"/>
+          <nav epub:type="toc">
+            <xsl:element name="{$toc.list.type}">
+              <xsl:call-template name="manual-toc">
+                <xsl:with-param name="tocentry" select="$tocentry/*[1]"/>
+              </xsl:call-template>
+            </xsl:element>
+          </nav>
+        </div>
+      </xsl:if>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:choose>
+        <xsl:when test="$qanda.in.toc != 0">
+          <xsl:if test="$nodes.plus">
+            <div class="toc">
+              <xsl:copy-of select="$toc.title"/>
+              <nav epub:type="toc">
+                <xsl:element name="{$toc.list.type}">
+                  <xsl:apply-templates select="$nodes.plus" mode="toc">
+                    <xsl:with-param name="toc-context" select="$toc-context"/>
+                  </xsl:apply-templates>
+                </xsl:element>
+              </nav>
+            </div>
+          </xsl:if>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:if test="$nodes">
+            <div class="toc">
+              <xsl:copy-of select="$toc.title"/>
+              <nav epub:type="toc">
+                <xsl:element name="{$toc.list.type}">
+                  <xsl:apply-templates select="$nodes" mode="toc">
+                    <xsl:with-param name="toc-context" select="$toc-context"/>
+                  </xsl:apply-templates>
+                </xsl:element>
+              </nav>
+            </div>
+          </xsl:if>
+        </xsl:otherwise>
+      </xsl:choose>
+
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!-- EPUB3: add hidden="" for sections below toc.section.depth -->
+<xsl:template name="subtoc">
+  <xsl:param name="toc-context" select="."/>
+  <xsl:param name="nodes" select="NOT-AN-ELEMENT"/>
+
+  <xsl:variable name="nodes.plus" select="$nodes | qandaset"/>
+
+  <xsl:variable name="depth">
+    <xsl:choose>
+      <xsl:when test="local-name(.) = 'section'">
+        <xsl:value-of select="count(ancestor::section) + 1"/>
+      </xsl:when>
+      <xsl:when test="local-name(.) = 'sect1'">1</xsl:when>
+      <xsl:when test="local-name(.) = 'sect2'">2</xsl:when>
+      <xsl:when test="local-name(.) = 'sect3'">3</xsl:when>
+      <xsl:when test="local-name(.) = 'sect4'">4</xsl:when>
+      <xsl:when test="local-name(.) = 'sect5'">5</xsl:when>
+      <xsl:when test="local-name(.) = 'refsect1'">1</xsl:when>
+      <xsl:when test="local-name(.) = 'refsect2'">2</xsl:when>
+      <xsl:when test="local-name(.) = 'refsect3'">3</xsl:when>
+      <xsl:when test="local-name(.) = 'simplesect'">
+        <!-- sigh... -->
+        <xsl:choose>
+          <xsl:when test="local-name(..) = 'section'">
+            <xsl:value-of select="count(ancestor::section)"/>
+          </xsl:when>
+          <xsl:when test="local-name(..) = 'sect1'">2</xsl:when>
+          <xsl:when test="local-name(..) = 'sect2'">3</xsl:when>
+          <xsl:when test="local-name(..) = 'sect3'">4</xsl:when>
+          <xsl:when test="local-name(..) = 'sect4'">5</xsl:when>
+          <xsl:when test="local-name(..) = 'sect5'">6</xsl:when>
+          <xsl:when test="local-name(..) = 'refsect1'">2</xsl:when>
+          <xsl:when test="local-name(..) = 'refsect2'">3</xsl:when>
+          <xsl:when test="local-name(..) = 'refsect3'">4</xsl:when>
+          <xsl:otherwise>1</xsl:otherwise>
+        </xsl:choose>
+      </xsl:when>
+      <xsl:otherwise>0</xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
+  <xsl:variable name="depth.from.context" select="count(ancestor::*)-count($toc-context/ancestor::*)"/>
+
+  <xsl:variable name="subtoc">
+    <xsl:element name="{$toc.list.type}">
+      <xsl:choose>
+        <xsl:when test="$toc.listitem.type = 'li'
+                  and $toc.section.depth > $depth and 
+                  ( ($qanda.in.toc = 0 and count($nodes)&gt;0) or
+                    ($qanda.in.toc != 0 and count($nodes.plus)&gt;0) )
+                  and $toc.max.depth > $depth.from.context">
+          <!-- No @hidden attribute -->
+        </xsl:when>
+        <xsl:otherwise>
+          <!-- Add empty @hidden attribute if too deep -->
+          <xsl:attribute name="hidden"></xsl:attribute>
+        </xsl:otherwise>
+      </xsl:choose>
+
+      <xsl:choose>
+        <xsl:when test="$qanda.in.toc != 0">
+          <xsl:apply-templates mode="toc" select="$nodes.plus">
+            <xsl:with-param name="toc-context" select="$toc-context"/>
+          </xsl:apply-templates>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:apply-templates mode="toc" select="$nodes">
+            <xsl:with-param name="toc-context" select="$toc-context"/>
+          </xsl:apply-templates>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:element>
+  </xsl:variable>
+
+  <xsl:variable name="subtoc.list">
+    <xsl:choose>
+      <xsl:when test="$toc.dd.type = ''">
+        <xsl:copy-of select="$subtoc"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:element name="{$toc.dd.type}">
+          <xsl:copy-of select="$subtoc"/>
+        </xsl:element>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:variable>
+
+  <xsl:element name="{$toc.listitem.type}">
+    <xsl:call-template name="toc.line">
+      <xsl:with-param name="toc-context" select="$toc-context"/>
+    </xsl:call-template>
+    <xsl:if test="$toc.listitem.type = 'li'
+                  and 
+                  ( ($qanda.in.toc = 0 and count($nodes)&gt;0) or
+                    ($qanda.in.toc != 0 and count($nodes.plus)&gt;0) ) ">
+      <xsl:copy-of select="$subtoc.list"/>
+    </xsl:if>
+  </xsl:element>
+</xsl:template>
+
+<!-- EPUB3: either <a> or <span>, but not both  -->
+<xsl:template name="toc.line">
+  <xsl:param name="toc-context" select="."/>
+  <xsl:param name="depth" select="1"/>
+  <xsl:param name="depth.from.context" select="8"/>
+
+
+  <a>
+    <xsl:attribute name="href">
+      <xsl:call-template name="href.target">
+        <xsl:with-param name="context" select="$toc-context"/>
+        <xsl:with-param name="toc-context" select="$toc-context"/>
+      </xsl:call-template>
+    </xsl:attribute>
+    
+    <!-- * if $autotoc.label.in.hyperlink is non-zero, then output the label -->
+    <!-- * as part of the hyperlinked title -->
+    <xsl:if test="not($autotoc.label.in.hyperlink = 0)">
+      <xsl:variable name="label">
+        <xsl:apply-templates select="." mode="label.markup"/>
+      </xsl:variable>
+      <xsl:copy-of select="$label"/>
+      <xsl:if test="$label != ''">
+        <xsl:value-of select="$autotoc.label.separator"/>
+      </xsl:if>
+    </xsl:if>
+
+    <xsl:apply-templates select="." mode="title.markup"/>
+  </a>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/xsl/epub3/profile-chunk.xsl b/xsl/epub3/profile-chunk.xsl
new file mode 100644 (file)
index 0000000..64ed1fe
--- /dev/null
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--This file was created automatically by html2xhtml-->
+<!--from the HTML stylesheets.-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" xmlns="http://www.w3.org/1999/xhtml" version="1.0" exclude-result-prefixes="exsl">
+
+<!-- ********************************************************************
+     $Id: profile-chunk.xsl,v 1.1 2011-09-16 21:43:45 bobs Exp $
+     ********************************************************************
+
+     This file is part of the XSL DocBook Stylesheet distribution.
+     See ../README or http://docbook.sf.net/release/xsl/current/ for
+     copyright and other information.
+
+     ******************************************************************** -->
+
+<!-- ==================================================================== -->
+
+<!-- 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"/>
+
+<!-- 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="../xhtml/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="../xhtml/profile-chunk-code.xsl"/>
+
+<xsl:include href="epub3-chunk-mods.xsl"/>
+
+</xsl:stylesheet>
diff --git a/xsl/epub3/profile-docbook.xsl b/xsl/epub3/profile-docbook.xsl
new file mode 100644 (file)
index 0000000..83183d0
--- /dev/null
@@ -0,0 +1,408 @@
+<?xml version="1.0" encoding="ASCII"?>
+<!--This file was created automatically by html2xhtml-->
+<!--from the HTML stylesheets.-->
+<!--This file was created automatically by xsl2profile-->
+<!--from the DocBook XSL stylesheets.-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ng="http://docbook.org/docbook-ng" xmlns:db="http://docbook.org/ns/docbook" xmlns:exsl="http://exslt.org/common" xmlns:exslt="http://exslt.org/common" xmlns="http://www.w3.org/1999/xhtml" exslt:dummy="dummy" ng:dummy="dummy" db:dummy="dummy" extension-element-prefixes="exslt" exclude-result-prefixes="db ng exsl exslt exslt" version="1.0">
+
+<xsl:output method="xml" encoding="UTF-8" indent="no"/>
+
+<!-- ********************************************************************
+     $Id: profile-docbook.xsl,v 1.1 2011-09-16 21:43:45 bobs Exp $
+     ********************************************************************
+
+     This file is part of the XSL DocBook Stylesheet distribution.
+     See ../README or http://docbook.sf.net/release/xsl/current/ for
+     copyright and other information.
+
+     ******************************************************************** -->
+
+<!-- ==================================================================== -->
+
+<xsl:include href="../VERSION"/>
+<xsl:include href="../xhtml/param.xsl"/>
+<xsl:include href="../lib/lib.xsl"/>
+<xsl:include href="../common/l10n.xsl"/>
+<xsl:include href="../common/common.xsl"/>
+<xsl:include href="../common/utility.xsl"/>
+<xsl:include href="../common/labels.xsl"/>
+<xsl:include href="../common/titles.xsl"/>
+<xsl:include href="../common/subtitles.xsl"/>
+<xsl:include href="../common/gentext.xsl"/>
+<xsl:include href="../common/targets.xsl"/>
+<xsl:include href="../common/olink.xsl"/>
+<xsl:include href="../common/pi.xsl"/>
+<xsl:include href="../xhtml/autotoc.xsl"/>
+<xsl:include href="../xhtml/autoidx.xsl"/>
+<xsl:include href="../xhtml/lists.xsl"/>
+<xsl:include href="../xhtml/callout.xsl"/>
+<xsl:include href="../xhtml/verbatim.xsl"/>
+<xsl:include href="../xhtml/graphics.xsl"/>
+<xsl:include href="../xhtml/xref.xsl"/>
+<xsl:include href="../xhtml/formal.xsl"/>
+<xsl:include href="../xhtml/table.xsl"/>
+<xsl:include href="../xhtml/htmltbl.xsl"/>
+<xsl:include href="../xhtml/sections.xsl"/>
+<xsl:include href="../xhtml/inline.xsl"/>
+<xsl:include href="../xhtml/footnote.xsl"/>
+<xsl:include href="../xhtml/html.xsl"/>
+<xsl:include href="../xhtml/info.xsl"/>
+<xsl:include href="../xhtml/keywords.xsl"/>
+<xsl:include href="../xhtml/division.xsl"/>
+<xsl:include href="../xhtml/toc.xsl"/>
+<xsl:include href="../xhtml/index.xsl"/>
+<xsl:include href="../xhtml/refentry.xsl"/>
+<xsl:include href="../xhtml/math.xsl"/>
+<xsl:include href="../xhtml/admon.xsl"/>
+<xsl:include href="../xhtml/component.xsl"/>
+<xsl:include href="../xhtml/biblio.xsl"/>
+<xsl:include href="../xhtml/biblio-iso690.xsl"/>
+<xsl:include href="../xhtml/glossary.xsl"/>
+<xsl:include href="../xhtml/block.xsl"/>
+<xsl:include href="../xhtml/task.xsl"/>
+<xsl:include href="../xhtml/qandaset.xsl"/>
+<xsl:include href="../xhtml/synop.xsl"/>
+<xsl:include href="../xhtml/titlepage.xsl"/>
+<xsl:include href="../xhtml/titlepage.templates.xsl"/>
+<xsl:include href="../xhtml/pi.xsl"/>
+<xsl:include href="../xhtml/ebnf.xsl"/>
+<xsl:include href="../xhtml/chunker.xsl"/>
+<xsl:include href="../xhtml/html-rtf.xsl"/>
+<xsl:include href="../xhtml/annotations.xsl"/>
+<xsl:include href="../common/stripns.xsl"/>
+
+<xsl:param name="stylesheet.result.type" select="'xhtml'"/>
+<xsl:param name="htmlhelp.output" select="0"/>
+
+<!-- ==================================================================== -->
+
+<xsl:key name="id" match="*" use="@id|@xml:id"/>
+<xsl:key name="gid" match="*" use="generate-id()"/>
+
+<!-- ==================================================================== -->
+
+<xsl:template match="*">
+  <xsl:message>
+    <xsl:text>Element </xsl:text>
+    <xsl:value-of select="local-name(.)"/>
+    <xsl:text> in namespace '</xsl:text>
+    <xsl:value-of select="namespace-uri(.)"/>
+    <xsl:text>' encountered</xsl:text>
+    <xsl:if test="parent::*">
+      <xsl:text> in </xsl:text>
+      <xsl:value-of select="name(parent::*)"/>
+    </xsl:if>
+    <xsl:text>, but no template matches.</xsl:text>
+  </xsl:message>
+
+  <span style="color: red">
+    <xsl:text>&lt;</xsl:text>
+    <xsl:value-of select="name(.)"/>
+    <xsl:text>&gt;</xsl:text>
+    <xsl:apply-templates/>
+    <xsl:text>&lt;/</xsl:text>
+    <xsl:value-of select="name(.)"/>
+    <xsl:text>&gt;</xsl:text>
+  </span>
+</xsl:template>
+
+<xsl:template match="text()">
+  <xsl:value-of select="."/>
+</xsl:template>
+
+<xsl:template name="body.attributes"><xslo:if xmlns:xslo="http://www.w3.org/1999/XSL/Transform" test="starts-with($writing.mode, 'rl')"><xslo:attribute name="dir">rtl</xslo:attribute></xslo:if>
+<!-- no apply-templates; make it empty except for dir for rtl-->
+</xsl:template>
+
+<xsl:template name="head.content">
+  <xsl:param name="node" select="."/>
+  <xsl:param name="title">
+    <xsl:apply-templates select="$node" mode="object.title.markup.textonly"/>
+  </xsl:param>
+
+  <title>
+    <xsl:copy-of select="$title"/>
+  </title>
+
+  <xsl:if test="$html.base != ''">
+    <base href="{$html.base}"/>
+  </xsl:if>
+
+  <!-- Insert links to CSS files or insert literal style elements -->
+  <xsl:call-template name="generate.css"/>
+
+  <xsl:if test="$html.stylesheet != ''">
+    <xsl:call-template name="output.html.stylesheets">
+      <xsl:with-param name="stylesheets" select="normalize-space($html.stylesheet)"/>
+    </xsl:call-template>
+  </xsl:if>
+
+  <xsl:if test="$link.mailto.url != ''">
+    <link rev="made" href="{$link.mailto.url}"/>
+  </xsl:if>
+
+  <meta name="generator" content="DocBook {$DistroTitle} V{$VERSION}"/>
+
+  <xsl:if test="$generate.meta.abstract != 0">
+    <xsl:variable name="info" select="(articleinfo                                       |bookinfo                                       |prefaceinfo                                       |chapterinfo                                       |appendixinfo                                       |sectioninfo                                       |sect1info                                       |sect2info                                       |sect3info                                       |sect4info                                       |sect5info                                       |referenceinfo                                       |refentryinfo                                       |partinfo                                       |info                                       |docinfo)[1]"/>
+    <xsl:if test="$info and $info/abstract">
+      <meta name="description">
+        <xsl:attribute name="content">
+          <xsl:for-each select="$info/abstract[1]/*">
+            <xsl:value-of select="normalize-space(.)"/>
+            <xsl:if test="position() &lt; last()">
+              <xsl:text> </xsl:text>
+            </xsl:if>
+          </xsl:for-each>
+        </xsl:attribute>
+      </meta>
+    </xsl:if>
+  </xsl:if>
+
+  <xsl:if test="($draft.mode = 'yes' or                 ($draft.mode = 'maybe' and                 ancestor-or-self::*[@status][1]/@status = 'draft'))                 and $draft.watermark.image != ''">
+    <style type="text/css"><xsl:text>
+body { background-image: url('</xsl:text>
+<xsl:value-of select="$draft.watermark.image"/><xsl:text>');
+       background-repeat: no-repeat;
+       background-position: top left;
+       /* The following properties make the watermark "fixed" on the page. */
+       /* I think that's just a bit too distracting for the reader... */
+       /* background-attachment: fixed; */
+       /* background-position: center center; */
+     }</xsl:text>
+    </style>
+  </xsl:if>
+  <xsl:apply-templates select="." mode="head.keywords.content"/>
+</xsl:template>
+
+<xsl:template name="output.html.stylesheets">
+  <xsl:param name="stylesheets" select="''"/>
+
+  <xsl:choose>
+    <xsl:when test="contains($stylesheets, ' ')">
+      <xsl:variable name="css.filename" select="substring-before($stylesheets, ' ')"/>
+
+      <xsl:call-template name="make.css.link">
+        <xsl:with-param name="css.filename" select="$css.filename"/>
+      </xsl:call-template>
+
+      <xsl:call-template name="output.html.stylesheets">
+        <xsl:with-param name="stylesheets" select="substring-after($stylesheets, ' ')"/>
+      </xsl:call-template>
+    </xsl:when>
+    <xsl:when test="$stylesheets != ''">
+      <xsl:call-template name="make.css.link">
+        <xsl:with-param name="css.filename" select="$stylesheets"/>
+      </xsl:call-template>
+    </xsl:when>
+  </xsl:choose>
+</xsl:template>
+
+<!-- ============================================================ -->
+
+<xsl:template match="*" mode="head.keywords.content">
+  <xsl:apply-templates select="chapterinfo/keywordset" mode="html.header"/>
+  <xsl:apply-templates select="appendixinfo/keywordset" mode="html.header"/>
+  <xsl:apply-templates select="prefaceinfo/keywordset" mode="html.header"/>
+  <xsl:apply-templates select="bookinfo/keywordset" mode="html.header"/>
+  <xsl:apply-templates select="setinfo/keywordset" mode="html.header"/>
+  <xsl:apply-templates select="articleinfo/keywordset" mode="html.header"/>
+  <xsl:apply-templates select="artheader/keywordset" mode="html.header"/>
+  <xsl:apply-templates select="sect1info/keywordset" mode="html.header"/>
+  <xsl:apply-templates select="sect2info/keywordset" mode="html.header"/>
+  <xsl:apply-templates select="sect3info/keywordset" mode="html.header"/>
+  <xsl:apply-templates select="sect4info/keywordset" mode="html.header"/>
+  <xsl:apply-templates select="sect5info/keywordset" mode="html.header"/>
+  <xsl:apply-templates select="sectioninfo/keywordset" mode="html.header"/>
+  <xsl:apply-templates select="refsect1info/keywordset" mode="html.header"/>
+  <xsl:apply-templates select="refsect2info/keywordset" mode="html.header"/>
+  <xsl:apply-templates select="refsect3info/keywordset" mode="html.header"/>
+  <xsl:apply-templates select="bibliographyinfo/keywordset" mode="html.header"/>
+  <xsl:apply-templates select="glossaryinfo/keywordset" mode="html.header"/>
+  <xsl:apply-templates select="indexinfo/keywordset" mode="html.header"/>
+  <xsl:apply-templates select="refentryinfo/keywordset" mode="html.header"/>
+  <xsl:apply-templates select="partinfo/keywordset" mode="html.header"/>
+  <xsl:apply-templates select="referenceinfo/keywordset" mode="html.header"/>
+  <xsl:apply-templates select="docinfo/keywordset" mode="html.header"/>
+  <xsl:apply-templates select="info/keywordset" mode="html.header"/>
+
+  <xsl:if test="$inherit.keywords != 0                 and parent::*">
+    <xsl:apply-templates select="parent::*" mode="head.keywords.content"/>
+  </xsl:if>
+</xsl:template>
+
+<!-- ============================================================ -->
+
+<xsl:template name="system.head.content">
+  <xsl:param name="node" select="."/>
+
+  <!-- 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">
+    <xsl:call-template name="add.annotation.links"/>
+    <script type="text/javascript">
+      <xsl:text>
+// Create PopupWindow objects</xsl:text>
+      <xsl:for-each select="//annotation">
+        <xsl:text>
+var popup_</xsl:text>
+        <xsl:value-of select="generate-id(.)"/>
+        <xsl:text> = new PopupWindow("popup-</xsl:text>
+        <xsl:value-of select="generate-id(.)"/>
+        <xsl:text>");
+</xsl:text>
+        <xsl:text>popup_</xsl:text>
+        <xsl:value-of select="generate-id(.)"/>
+        <xsl:text>.offsetY = 15;
+</xsl:text>
+        <xsl:text>popup_</xsl:text>
+        <xsl:value-of select="generate-id(.)"/>
+        <xsl:text>.autoHide();
+</xsl:text>
+      </xsl:for-each>
+    </script>
+
+    <style type="text/css">
+      <xsl:value-of select="$annotation.css"/>
+    </style>
+  </xsl:if>
+
+  <!-- system.head.content is like user.head.content, except that
+       it is called before head.content. This is important because it
+       means, for example, that <style> elements output by system.head.content
+       have a lower CSS precedence than the users stylesheet. -->
+</xsl:template>
+
+<!-- ============================================================ -->
+
+<xsl:template name="user.preroot">
+  <!-- Pre-root output, can be used to output comments and PIs. -->
+  <!-- This must not output any element content! -->
+</xsl:template>
+
+<xsl:template name="user.head.content">
+  <xsl:param name="node" select="."/>
+</xsl:template>
+
+<xsl:template name="user.header.navigation">
+  <xsl:param name="node" select="."/>
+</xsl:template>
+
+<xsl:template name="user.header.content">
+  <xsl:param name="node" select="."/>
+</xsl:template>
+
+<xsl:template name="user.footer.content">
+  <xsl:param name="node" select="."/>
+</xsl:template>
+
+<xsl:template name="user.footer.navigation">
+  <xsl:param name="node" select="."/>
+</xsl:template>
+
+<xslo:include xmlns:xslo="http://www.w3.org/1999/XSL/Transform" href="../profiling/profile-mode.xsl"/><xslo:variable xmlns:xslo="http://www.w3.org/1999/XSL/Transform" name="profiled-content"><xslo:choose><xslo:when test="*/self::ng:* or */self::db:*"><xslo:message>Note: namesp. cut : stripped namespace before processing</xslo:message><xslo:variable name="stripped-content"><xslo:apply-templates select="/" mode="stripNS"/></xslo:variable><xslo:message>Note: namesp. cut : processing stripped document</xslo:message><xslo:apply-templates select="exslt:node-set($stripped-content)" mode="profile"/></xslo:when><xslo:otherwise><xslo:apply-templates select="/" mode="profile"/></xslo:otherwise></xslo:choose></xslo:variable><xslo:variable xmlns:xslo="http://www.w3.org/1999/XSL/Transform" name="profiled-nodes" select="exslt:node-set($profiled-content)"/><xsl:template match="/">
+  <!-- * Get a title for current doc so that we let the user -->
+  <!-- * know what document we are processing at this point. -->
+  <xsl:variable name="doc.title">
+    <xsl:call-template name="get.doc.title"/>
+  </xsl:variable>
+  <xsl:choose>
+    <!-- Hack! If someone hands us a DocBook V5.x or DocBook NG document,
+         toss the namespace and continue.  Use the docbook5 namespaced
+         stylesheets for DocBook5 if you don't want to use this feature.-->
+    <!-- include extra test for Xalan quirk -->
+    <xsl:when test="false()"/>
+    <!-- Can't process unless namespace removed -->
+    <xsl:when test="false()"/>
+    <xsl:otherwise>
+      <xsl:choose>
+        <xsl:when test="$rootid != ''">
+          <xsl:choose>
+            <xsl:when test="count($profiled-nodes//*[@id=$rootid]) = 0">
+              <xsl:message terminate="yes">
+                <xsl:text>ID '</xsl:text>
+                <xsl:value-of select="$rootid"/>
+                <xsl:text>' not found in document.</xsl:text>
+              </xsl:message>
+            </xsl:when>
+            <xsl:otherwise>
+              <xsl:if test="$collect.xref.targets = 'yes' or                             $collect.xref.targets = 'only'">
+                <xsl:apply-templates select="key('id', $rootid)" mode="collect.targets"/>
+              </xsl:if>
+              <xsl:if test="$collect.xref.targets != 'only'">
+                <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid]" mode="process.root"/>
+                <xsl:if test="$tex.math.in.alt != ''">
+                  <xsl:apply-templates select="$profiled-nodes//*[@id=$rootid]" mode="collect.tex.math"/>
+                </xsl:if>
+              </xsl:if>
+            </xsl:otherwise>
+          </xsl:choose>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:if test="$collect.xref.targets = 'yes' or                         $collect.xref.targets = 'only'">
+            <xsl:apply-templates select="$profiled-nodes" mode="collect.targets"/>
+          </xsl:if>
+          <xsl:if test="$collect.xref.targets != 'only'">
+            <xsl:apply-templates select="$profiled-nodes" mode="process.root"/>
+            <xsl:if test="$tex.math.in.alt != ''">
+              <xsl:apply-templates select="$profiled-nodes" mode="collect.tex.math"/>
+            </xsl:if>
+          </xsl:if>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template match="*" mode="process.root">
+  <xsl:variable name="doc" select="self::*"/>
+
+  <xsl:call-template name="user.preroot"/>
+  <xsl:call-template name="root.messages"/>
+
+  <html>
+    <head>
+      <xsl:call-template name="system.head.content">
+        <xsl:with-param name="node" select="$doc"/>
+      </xsl:call-template>
+      <xsl:call-template name="head.content">
+        <xsl:with-param name="node" select="$doc"/>
+      </xsl:call-template>
+      <xsl:call-template name="user.head.content">
+        <xsl:with-param name="node" select="$doc"/>
+      </xsl:call-template>
+    </head>
+    <body>
+      <xsl:call-template name="body.attributes"/>
+      <xsl:call-template name="user.header.content">
+        <xsl:with-param name="node" select="$doc"/>
+      </xsl:call-template>
+      <xsl:apply-templates select="."/>
+      <xsl:call-template name="user.footer.content">
+        <xsl:with-param name="node" select="$doc"/>
+      </xsl:call-template>
+    </body>
+  </html>
+  <xsl:value-of select="$html.append"/>
+  
+  <!-- Generate any css files only once, not once per chunk -->
+  <xsl:call-template name="generate.css.files"/>
+</xsl:template>
+
+<xsl:template name="root.messages">
+  <!-- redefine this any way you'd like to output messages -->
+  <!-- DO NOT OUTPUT ANYTHING FROM THIS TEMPLATE -->
+</xsl:template>
+
+<!-- ==================================================================== -->
+
+<xsl:template name="chunk">
+  <xsl:param name="node" select="."/>
+
+  <!-- The default is that we are not chunking... -->
+  <xsl:text>0</xsl:text>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/xsl/epub3/titlepage.templates.xml b/xsl/epub3/titlepage.templates.xml
new file mode 100644 (file)
index 0000000..c9b8ee5
--- /dev/null
@@ -0,0 +1,712 @@
+<t:templates xmlns:t="http://nwalsh.com/docbook/xsl/template/1.0"
+             xmlns:param="http://nwalsh.com/docbook/xsl/template/1.0/param"
+             xmlns="http://www.w3.org/1999/xhtml"
+             xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<!-- ==================================================================== -->
+
+<t:titlepage t:element="article" t:wrapper="div" class="titlepage">
+  <t:titlepage-content t:side="recto">
+    <title/>
+    <subtitle/>
+    <corpauthor/>
+    <authorgroup/>
+    <author/>
+    <othercredit/>
+    <releaseinfo/>
+    <copyright/>
+    <legalnotice/>
+    <pubdate/>
+    <revision/>
+    <revhistory/>
+    <abstract/>
+  </t:titlepage-content>
+
+  <t:titlepage-content t:side="verso">
+  </t:titlepage-content>
+
+  <t:titlepage-separator>
+    <hr/>
+  </t:titlepage-separator>
+
+  <t:titlepage-before t:side="recto">
+  </t:titlepage-before>
+
+  <t:titlepage-before t:side="verso">
+  </t:titlepage-before>
+</t:titlepage>
+
+<!-- ==================================================================== -->
+
+<t:titlepage t:element="set" t:wrapper="div" class="titlepage">
+  <t:titlepage-content t:side="recto">
+    <title/>
+    <subtitle/>
+    <corpauthor/>
+    <authorgroup/>
+    <author/>
+    <othercredit/>
+    <releaseinfo/>
+    <copyright/>
+    <legalnotice/>
+    <pubdate/>
+    <revision/>
+    <revhistory/>
+    <abstract/>
+  </t:titlepage-content>
+
+  <t:titlepage-content t:side="verso">
+  </t:titlepage-content>
+
+  <t:titlepage-separator>
+    <hr/>
+  </t:titlepage-separator>
+
+  <t:titlepage-before t:side="recto">
+  </t:titlepage-before>
+
+  <t:titlepage-before t:side="verso">
+  </t:titlepage-before>
+</t:titlepage>
+
+<!-- ==================================================================== -->
+
+<t:titlepage t:element="book" t:wrapper="div" class="titlepage">
+  <t:titlepage-content t:side="recto">
+    <title/>
+    <subtitle/>
+    <isbn/>
+    <issn/>
+    <biblioid/>
+    <corpauthor/>
+    <authorgroup/>
+    <author/>
+    <othercredit/>
+    <releaseinfo/>
+    <copyright/>
+    <legalnotice/>
+    <pubdate/>
+    <revision/>
+    <revhistory/>
+    <abstract/>
+  </t:titlepage-content>
+
+  <t:titlepage-content t:side="verso">
+  </t:titlepage-content>
+
+  <t:titlepage-separator>
+    <hr/>
+  </t:titlepage-separator>
+
+  <t:titlepage-before t:side="recto">
+  </t:titlepage-before>
+
+  <t:titlepage-before t:side="verso">
+  </t:titlepage-before>
+</t:titlepage>
+
+<!-- ==================================================================== -->
+
+<t:titlepage t:element="part" t:wrapper="div" class="titlepage">
+  <t:titlepage-content t:side="recto">
+    <title
+           t:force="1"
+           t:named-template="division.title"
+           param:node="ancestor-or-self::part[1]"/>
+    <subtitle/>
+    <corpauthor/>
+    <authorgroup/>
+    <author/>
+    <othercredit/>
+    <releaseinfo/>
+    <copyright/>
+    <legalnotice/>
+    <pubdate/>
+    <revision/>
+    <revhistory/>
+    <abstract/>
+  </t:titlepage-content>
+
+  <t:titlepage-content t:side="verso">
+  </t:titlepage-content>
+
+  <t:titlepage-separator>
+  </t:titlepage-separator>
+
+  <t:titlepage-before t:side="recto">
+  </t:titlepage-before>
+
+  <t:titlepage-before t:side="verso">
+  </t:titlepage-before>
+</t:titlepage>
+
+<t:titlepage t:element="partintro" t:wrapper="div">
+  <t:titlepage-content t:side="recto">
+    <title/>
+    <subtitle/>
+    <corpauthor/>
+    <authorgroup/>
+    <author/>
+    <othercredit/>
+    <releaseinfo/>
+    <copyright/>
+    <legalnotice/>
+    <pubdate/>
+    <revision/>
+    <revhistory/>
+    <abstract/>
+  </t:titlepage-content>
+
+  <t:titlepage-content t:side="verso">
+  </t:titlepage-content>
+
+  <t:titlepage-separator>
+  </t:titlepage-separator>
+
+  <t:titlepage-before t:side="recto">
+  </t:titlepage-before>
+
+  <t:titlepage-before t:side="verso">
+  </t:titlepage-before>
+</t:titlepage>
+
+<!-- ==================================================================== -->
+
+<t:titlepage t:element="reference" t:wrapper="div" class="titlepage">
+  <t:titlepage-content t:side="recto">
+    <title/>
+    <subtitle/>
+    <corpauthor/>
+    <authorgroup/>
+    <author/>
+    <othercredit/>
+    <releaseinfo/>
+    <copyright/>
+    <legalnotice/>
+    <pubdate/>
+    <revision/>
+    <revhistory/>
+    <abstract/>
+  </t:titlepage-content>
+
+  <t:titlepage-content t:side="verso">
+  </t:titlepage-content>
+
+  <t:titlepage-separator>
+    <hr/>
+  </t:titlepage-separator>
+
+  <t:titlepage-before t:side="recto">
+  </t:titlepage-before>
+
+  <t:titlepage-before t:side="verso">
+  </t:titlepage-before>
+</t:titlepage>
+
+<!-- ==================================================================== -->
+
+<t:titlepage t:element="refentry" t:wrapper="div" class="titlepage">
+  <t:titlepage-content t:side="recto">
+<!-- uncomment this if you want refentry titlepages
+    <title t:force="1"
+           t:named-template="refentry.title"
+           param:node="ancestor-or-self::refentry[1]"/>
+-->
+  </t:titlepage-content>
+
+  <t:titlepage-content t:side="verso">
+  </t:titlepage-content>
+
+  <t:titlepage-separator/>
+
+  <t:titlepage-before t:side="recto">
+  </t:titlepage-before>
+
+  <t:titlepage-before t:side="verso">
+  </t:titlepage-before>
+</t:titlepage>
+
+<!-- ==================================================================== -->
+
+  <t:titlepage t:element="dedication" t:wrapper="div" class="titlepage">
+    <t:titlepage-content t:side="recto">
+    <title
+           t:force="1"
+           t:named-template="component.title"
+           param:node="ancestor-or-self::dedication[1]"/>
+    <subtitle/>
+    </t:titlepage-content>
+
+  <t:titlepage-content t:side="verso">
+  </t:titlepage-content>
+
+  <t:titlepage-separator>
+  </t:titlepage-separator>
+
+  <t:titlepage-before t:side="recto">
+  </t:titlepage-before>
+
+  <t:titlepage-before t:side="verso">
+  </t:titlepage-before>
+</t:titlepage>
+
+<!-- ==================================================================== -->
+
+<t:titlepage t:element="acknowledgements" t:wrapper="div" class="titlepage">
+    <t:titlepage-content t:side="recto">
+    <title
+           t:force="1"
+           t:named-template="component.title"
+           param:node="ancestor-or-self::acknowledgements[1]"/>
+    <subtitle/>
+    </t:titlepage-content>
+
+  <t:titlepage-content t:side="verso">
+  </t:titlepage-content>
+
+  <t:titlepage-separator>
+  </t:titlepage-separator>
+
+  <t:titlepage-before t:side="recto">
+  </t:titlepage-before>
+
+  <t:titlepage-before t:side="verso">
+  </t:titlepage-before>
+</t:titlepage>
+
+<!-- ==================================================================== -->
+
+<t:titlepage t:element="preface" t:wrapper="div" class="titlepage">
+  <t:titlepage-content t:side="recto">
+    <title/>
+    <subtitle/>
+    <corpauthor/>
+    <authorgroup/>
+    <author/>
+    <othercredit/>
+    <releaseinfo/>
+    <copyright/>
+    <legalnotice/>
+    <pubdate/>
+    <revision/>
+    <revhistory/>
+    <abstract/>
+  </t:titlepage-content>
+
+  <t:titlepage-content t:side="verso">
+  </t:titlepage-content>
+
+  <t:titlepage-separator>
+  </t:titlepage-separator>
+
+  <t:titlepage-before t:side="recto">
+  </t:titlepage-before>
+
+  <t:titlepage-before t:side="verso">
+  </t:titlepage-before>
+</t:titlepage>
+
+<!-- ==================================================================== -->
+
+<t:titlepage t:element="chapter" t:wrapper="div" class="titlepage">
+  <t:titlepage-content t:side="recto">
+    <title/>
+    <subtitle/>
+    <corpauthor/>
+    <authorgroup/>
+    <author/>
+    <othercredit/>
+    <releaseinfo/>
+    <copyright/>
+    <legalnotice/>
+    <pubdate/>
+    <revision/>
+    <revhistory/>
+    <abstract/>
+  </t:titlepage-content>
+
+  <t:titlepage-content t:side="verso">
+  </t:titlepage-content>
+
+  <t:titlepage-separator>
+  </t:titlepage-separator>
+
+  <t:titlepage-before t:side="recto">
+  </t:titlepage-before>
+
+  <t:titlepage-before t:side="verso">
+  </t:titlepage-before>
+</t:titlepage>
+
+<!-- ==================================================================== -->
+
+<t:titlepage t:element="appendix" t:wrapper="div" class="titlepage">
+  <t:titlepage-content t:side="recto">
+    <title/>
+    <subtitle/>
+    <corpauthor/>
+    <authorgroup/>
+    <author/>
+    <othercredit/>
+    <releaseinfo/>
+    <copyright/>
+    <legalnotice/>
+    <pubdate/>
+    <revision/>
+    <revhistory/>
+    <abstract/>
+  </t:titlepage-content>
+
+  <t:titlepage-content t:side="verso">
+  </t:titlepage-content>
+
+  <t:titlepage-separator>
+  </t:titlepage-separator>
+
+  <t:titlepage-before t:side="recto">
+  </t:titlepage-before>
+
+  <t:titlepage-before t:side="verso">
+  </t:titlepage-before>
+</t:titlepage>
+
+<!-- ==================================================================== -->
+
+<t:titlepage t:element="section" t:wrapper="div" class="titlepage">
+  <t:titlepage-content t:side="recto">
+    <title/>
+    <subtitle/>
+    <corpauthor/>
+    <authorgroup/>
+    <author/>
+    <othercredit/>
+    <releaseinfo/>
+    <copyright/>
+    <legalnotice/>
+    <pubdate/>
+    <revision/>
+    <revhistory/>
+    <abstract/>
+  </t:titlepage-content>
+
+  <t:titlepage-content t:side="verso">
+  </t:titlepage-content>
+
+  <t:titlepage-separator>
+    <xsl:if test="count(parent::*)='0'"><hr/></xsl:if>
+  </t:titlepage-separator>
+
+  <t:titlepage-before t:side="recto">
+  </t:titlepage-before>
+
+  <t:titlepage-before t:side="verso">
+  </t:titlepage-before>
+</t:titlepage>
+
+<t:titlepage t:element="sect1" t:wrapper="div" class="titlepage">
+  <t:titlepage-content t:side="recto">
+    <title/>
+    <subtitle/>
+    <corpauthor/>
+    <authorgroup/>
+    <author/>
+    <othercredit/>
+    <releaseinfo/>
+    <copyright/>
+    <legalnotice/>
+    <pubdate/>
+    <revision/>
+    <revhistory/>
+    <abstract/>
+  </t:titlepage-content>
+
+  <t:titlepage-content t:side="verso">
+  </t:titlepage-content>
+
+  <t:titlepage-separator>
+    <xsl:if test="count(parent::*)='0'"><hr/></xsl:if>
+  </t:titlepage-separator>
+
+  <t:titlepage-before t:side="recto">
+  </t:titlepage-before>
+
+  <t:titlepage-before t:side="verso">
+  </t:titlepage-before>
+</t:titlepage>
+
+<t:titlepage t:element="sect2" t:wrapper="div" class="titlepage">
+  <t:titlepage-content t:side="recto">
+    <title/>
+    <subtitle/>
+    <corpauthor/>
+    <authorgroup/>
+    <author/>
+    <othercredit/>
+    <releaseinfo/>
+    <copyright/>
+    <legalnotice/>
+    <pubdate/>
+    <revision/>
+    <revhistory/>
+    <abstract/>
+  </t:titlepage-content>
+
+  <t:titlepage-content t:side="verso">
+  </t:titlepage-content>
+
+  <t:titlepage-separator>
+    <xsl:if test="count(parent::*)='0'"><hr/></xsl:if>
+  </t:titlepage-separator>
+
+  <t:titlepage-before t:side="recto">
+  </t:titlepage-before>
+
+  <t:titlepage-before t:side="verso">
+  </t:titlepage-before>
+</t:titlepage>
+
+<t:titlepage t:element="sect3" t:wrapper="div" class="titlepage">
+  <t:titlepage-content t:side="recto">
+    <title/>
+    <subtitle/>
+    <corpauthor/>
+    <authorgroup/>
+    <author/>
+    <othercredit/>
+    <releaseinfo/>
+    <copyright/>
+    <legalnotice/>
+    <pubdate/>
+    <revision/>
+    <revhistory/>
+    <abstract/>
+  </t:titlepage-content>
+
+  <t:titlepage-content t:side="verso">
+  </t:titlepage-content>
+
+  <t:titlepage-separator>
+    <xsl:if test="count(parent::*)='0'"><hr/></xsl:if>
+  </t:titlepage-separator>
+
+  <t:titlepage-before t:side="recto">
+  </t:titlepage-before>
+
+  <t:titlepage-before t:side="verso">
+  </t:titlepage-before>
+</t:titlepage>
+
+<t:titlepage t:element="sect4" t:wrapper="div" class="titlepage">
+  <t:titlepage-content t:side="recto">
+    <title/>
+    <subtitle/>
+    <corpauthor/>
+    <authorgroup/>
+    <author/>
+    <othercredit/>
+    <releaseinfo/>
+    <copyright/>
+    <legalnotice/>
+    <pubdate/>
+    <revision/>
+    <revhistory/>
+    <abstract/>
+  </t:titlepage-content>
+
+  <t:titlepage-content t:side="verso">
+  </t:titlepage-content>
+
+  <t:titlepage-separator>
+    <xsl:if test="count(parent::*)='0'"><hr/></xsl:if>
+  </t:titlepage-separator>
+
+  <t:titlepage-before t:side="recto">
+  </t:titlepage-before>
+
+  <t:titlepage-before t:side="verso">
+  </t:titlepage-before>
+</t:titlepage>
+
+<t:titlepage t:element="sect5" t:wrapper="div" class="titlepage">
+  <t:titlepage-content t:side="recto">
+    <title/>
+    <subtitle/>
+    <corpauthor/>
+    <authorgroup/>
+    <author/>
+    <othercredit/>
+    <releaseinfo/>
+    <copyright/>
+    <legalnotice/>
+    <pubdate/>
+    <revision/>
+    <revhistory/>
+    <abstract/>
+  </t:titlepage-content>
+
+  <t:titlepage-content t:side="verso">
+  </t:titlepage-content>
+
+  <t:titlepage-separator>
+    <xsl:if test="count(parent::*)='0'"><hr/></xsl:if>
+  </t:titlepage-separator>
+
+  <t:titlepage-before t:side="recto">
+  </t:titlepage-before>
+
+  <t:titlepage-before t:side="verso">
+  </t:titlepage-before>
+</t:titlepage>
+
+<t:titlepage t:element="simplesect" t:wrapper="div" class="titlepage">
+  <t:titlepage-content t:side="recto">
+    <title/>
+    <subtitle/>
+    <corpauthor/>
+    <authorgroup/>
+    <author/>
+    <othercredit/>
+    <releaseinfo/>
+    <copyright/>
+    <legalnotice/>
+    <pubdate/>
+    <revision/>
+    <revhistory/>
+    <abstract/>
+  </t:titlepage-content>
+
+  <t:titlepage-content t:side="verso">
+  </t:titlepage-content>
+
+  <t:titlepage-separator>
+    <xsl:if test="count(parent::*)='0'"><hr/></xsl:if>
+  </t:titlepage-separator>
+
+  <t:titlepage-before t:side="recto">
+  </t:titlepage-before>
+
+  <t:titlepage-before t:side="verso">
+  </t:titlepage-before>
+</t:titlepage>
+
+<!-- ==================================================================== -->
+
+<t:titlepage t:element="bibliography" t:wrapper="div" class="titlepage">
+  <t:titlepage-content t:side="recto">
+    <title
+           t:force="1"
+           t:named-template="component.title"
+           param:node="ancestor-or-self::bibliography[1]"/>
+    <subtitle/>
+  </t:titlepage-content>
+
+  <t:titlepage-content t:side="verso">
+  </t:titlepage-content>
+
+  <t:titlepage-separator>
+  </t:titlepage-separator>
+
+  <t:titlepage-before t:side="recto">
+  </t:titlepage-before>
+
+  <t:titlepage-before t:side="verso">
+  </t:titlepage-before>
+</t:titlepage>
+
+<!-- ==================================================================== -->
+
+<t:titlepage t:element="glossary" t:wrapper="div" class="titlepage">
+  <t:titlepage-content t:side="recto">
+    <title
+           t:force="1"
+           t:named-template="component.title"
+           param:node="ancestor-or-self::glossary[1]"/>
+    <subtitle/>
+  </t:titlepage-content>
+
+  <t:titlepage-content t:side="verso">
+  </t:titlepage-content>
+
+  <t:titlepage-separator>
+  </t:titlepage-separator>
+
+  <t:titlepage-before t:side="recto">
+  </t:titlepage-before>
+
+  <t:titlepage-before t:side="verso">
+  </t:titlepage-before>
+</t:titlepage>
+
+<!-- ==================================================================== -->
+
+<t:titlepage t:element="index" t:wrapper="div" class="titlepage">
+  <t:titlepage-content t:side="recto">
+    <title
+           t:force="1"
+           t:named-template="component.title"
+           param:node="ancestor-or-self::index[1]"/>
+    <subtitle/>
+  </t:titlepage-content>
+
+  <t:titlepage-content t:side="verso">
+  </t:titlepage-content>
+
+  <t:titlepage-separator>
+  </t:titlepage-separator>
+
+  <t:titlepage-before t:side="recto">
+  </t:titlepage-before>
+
+  <t:titlepage-before t:side="verso">
+  </t:titlepage-before>
+</t:titlepage>
+
+<!-- ==================================================================== -->
+
+<t:titlepage t:element="setindex" t:wrapper="div" class="titlepage">
+  <t:titlepage-content t:side="recto">
+    <title
+           t:force="1"
+           t:named-template="component.title"
+           param:node="ancestor-or-self::setindex[1]"/>
+    <subtitle/>
+  </t:titlepage-content>
+
+  <t:titlepage-content t:side="verso">
+  </t:titlepage-content>
+
+  <t:titlepage-separator>
+  </t:titlepage-separator>
+
+  <t:titlepage-before t:side="recto">
+  </t:titlepage-before>
+
+  <t:titlepage-before t:side="verso">
+  </t:titlepage-before>
+</t:titlepage>
+
+<!-- ==================================================================== -->
+<t:titlepage t:element="sidebar" t:wrapper="div" class="titlepage">
+  <t:titlepage-content t:side="recto">
+    <title
+           t:named-template="formal.object.heading"
+           param:object="ancestor-or-self::sidebar[1]"/>
+    <subtitle/>
+  </t:titlepage-content>
+
+  <t:titlepage-content t:side="verso">
+  </t:titlepage-content>
+
+  <t:titlepage-separator>
+  </t:titlepage-separator>
+
+  <t:titlepage-before t:side="recto">
+  </t:titlepage-before>
+
+  <t:titlepage-before t:side="verso">
+  </t:titlepage-before>
+</t:titlepage>
+
+<!-- ==================================================================== -->
+
+</t:templates>