Showing:

Documentation
Used by
References
Supersedes
Imported modules
Imported from
Source
Stylesheet tei-to-epub.xsl
Documentation

Description

TEI stylesheet for making ePub output. A lot learnt from http://www.hxa.name/articles/content/epub-guide_hxa7241_2007.html and the stylesheets of the NZETC.

This software is dual-licensed: 1. Distributed under a Creative Commons Attribution-ShareAlike 3.0 Unported License http://creativecommons.org/licenses/by-sa/3.0/ 2. http://www.opensource.org/licenses/BSD-2-Clause All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. This software is provided by the copyright holders and contributors "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the copyright holder or contributors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.

Author: See AUTHORS

Id: $Id: tei-to-epub.xsl 9669 2011-11-07 19:17:54Z rahtz $

Copyright: 2008, TEI Consortium

Imported modules
Imported from
Stylesheet version 2.0
Template /
Documentation

Description

(extensible) wrapper for root element
Namespace No namespace
Match /
Mode #default
References
Template processTEI
Supersedes
Template /
Import precedence 6
Source
<xsl:template match="/">
  <xsl:call-template name="processTEI"/>
</xsl:template>
Stylesheet location ../../../epub/tei-to-epub.xsl
Template processTEI
Documentation

Description

[epub] Override of top-level template. This does most of the work: performing the normal transformation, fixing the links to graphics files so that they are all relative, creating the extra output files, etc
Namespace No namespace
Used by
Templates /; /
References
Supersedes
Template processTEI
Import precedence 6
Source
<xsl:template name="processTEI">
  <xsl:variable name="stage1">
    <xsl:apply-templates mode="preflight"/>
  </xsl:variable>
  <xsl:for-each select="$stage1">
    <xsl:call-template name="processTEIHook"/>
    <xsl:variable name="coverImageOutside">
      <xsl:choose>
        <xsl:when test="/tei:TEI/tei:text/tei:front/tei:titlePage[@facs]">
          <xsl:for-each select="/tei:TEI/tei:text/tei:front/tei:titlePage[@facs][1]">
            <xsl:for-each select="id(substring(@facs,2))">
              <xsl:choose>
                <xsl:when test="count(tei:graphic)=1">
                  <xsl:value-of select="tei:graphic/@url"/>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:value-of select="tei:graphic[2]/@url"/>
                </xsl:otherwise>
              </xsl:choose>
            </xsl:for-each>
          </xsl:for-each>
        </xsl:when>
        <xsl:when test="not($coverimage='')">
          <xsl:value-of select="$coverimage"/>
        </xsl:when>
      </xsl:choose>
    </xsl:variable>
    <xsl:variable name="coverImageInside">
      <xsl:choose>
        <xsl:when test="/tei:TEI/tei:text/tei:front/tei:titlePage[@facs]">
          <xsl:for-each select="/tei:TEI/tei:text/tei:front/tei:titlePage[@facs][1]">
            <xsl:for-each select="id(substring(@facs,2))">
              <xsl:value-of select="tei:graphic[1]/@url"/>
            </xsl:for-each>
          </xsl:for-each>
        </xsl:when>
        <xsl:when test="not($coverimage='')">
          <xsl:value-of select="$coverimage"/>
        </xsl:when>
      </xsl:choose>
    </xsl:variable>
    <xsl:choose>
      <xsl:when test="$splitLevel='-1'">
        <xsl:apply-templates/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:apply-templates mode="split"/>
      </xsl:otherwise>
    </xsl:choose>
    <xsl:for-each select="*">
      <xsl:variable name="TOC">
        <TOC xmlns="http://www.w3.org/1999/xhtml">
          <xsl:call-template name="mainTOC"/>
        </TOC>
      </xsl:variable>
      <!--
	    <xsl:result-document href="/tmp/TOC">
	    <xsl:copy-of select="$TOC"/>
	    </xsl:result-document>
-->
      <xsl:for-each select="tokenize($javascriptFiles,',')">
        <xsl:variable name="file" select="normalize-space(.)"/>
        <xsl:variable name="name" select="tokenize($file,'/')[last()]"/>
        <xsl:if test="$verbose='true'">
          <xsl:message>write Javascript file
            <xsl:value-of select="$name"/>
          </xsl:message>
        </xsl:if>
        <xsl:result-document method="text" href="{concat($directory,'/OEBPS/',$name)}">
          <xsl:for-each select="unparsed-text($file)">
            <xsl:copy-of select="."/>
          </xsl:for-each>
        </xsl:result-document>
      </xsl:for-each>
      <xsl:if test="$verbose='true'">
        <xsl:message>write file OEBPS/stylesheet.css</xsl:message>
      </xsl:if>
      <xsl:result-document method="text" href="{concat($directory,'/OEBPS/stylesheet.css')}">
        <xsl:if test="not($cssFile='')">
          <xsl:if test="$verbose='true'">
            <xsl:message>reading file
              <xsl:value-of select="$cssFile"/>
            </xsl:message>
          </xsl:if>
          <xsl:for-each select="tokenize(unparsed-text($cssFile),     '\r?\n')">
            <xsl:call-template name="purgeCSS"/>
          </xsl:for-each>
        </xsl:if>
        <xsl:if test="not($cssSecondaryFile='')">
          <xsl:if test="$verbose='true'">
            <xsl:message>reading secondary file
              <xsl:value-of select="$cssSecondaryFile"/>
            </xsl:message>
          </xsl:if>
          <xsl:for-each select="tokenize(unparsed-text($cssSecondaryFile),       '\r?\n')">
            <xsl:call-template name="purgeCSS"/>
          </xsl:for-each>
        </xsl:if>
        <xsl:if test="$odd='true'">
          <xsl:if test="$verbose='true'">
            <xsl:message>reading file
              <xsl:value-of select="$cssODDFile"/>
            </xsl:message>
          </xsl:if>
          <xsl:for-each select="tokenize(unparsed-text($cssODDFile),         '\r?\n')">
            <xsl:call-template name="purgeCSS"/>
          </xsl:for-each>
        </xsl:if>
        <xsl:if test="$odd='true'">
          <xsl:if test="$verbose='true'">
            <xsl:message>reading file
              <xsl:value-of select="$cssODDFile"/>
            </xsl:message>
          </xsl:if>
          <xsl:for-each select="tokenize(unparsed-text($cssODDFile),         '\r?\n')">
            <xsl:call-template name="purgeCSS"/>
          </xsl:for-each>
        </xsl:if>
        <xsl:if test="$filePerPage='true'">
          <xsl:text>body { width: </xsl:text>
          <xsl:value-of select="$viewPortWidth"/>
          <xsl:text>px;
 height: </xsl:text>
          <xsl:value-of select="$viewPortHeight"/>
          <xsl:text>px;
}
img.fullpage {
position: absolute;
height: </xsl:text>
          <xsl:value-of select="$viewPortHeight"/>
          <xsl:text>px; left:0px; top:0px;}
</xsl:text>
        </xsl:if>
      </xsl:result-document>
      <xsl:if test="$verbose='true'">
        <xsl:message>write file OEBPS/print.css</xsl:message>
      </xsl:if>
      <xsl:result-document method="text" href="{concat($directory,'/OEBPS/print.css')}">
        <xsl:if test="$verbose='true'">
          <xsl:message>reading file
            <xsl:value-of select="$cssPrintFile"/>
          </xsl:message>
        </xsl:if>
        <xsl:for-each select="tokenize(unparsed-text($cssPrintFile),     '\r?\n')">
          <xsl:call-template name="purgeCSS"/>
        </xsl:for-each>
      </xsl:result-document>
      <xsl:if test="$verbose='true'">
        <xsl:message>write file mimetype</xsl:message>
      </xsl:if>
      <xsl:result-document method="text" href="{concat($directory,'/mimetype')}">
        <xsl:text>application/epub+zip</xsl:text>
      </xsl:result-document>
      <xsl:if test="$verbose='true'">
        <xsl:message>write file META-INF/container.xml</xsl:message>
      </xsl:if>
      <xsl:result-document method="xml" href="{concat($directory,'/META-INF/container.xml')}">
        <container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" version="1.0">
          <rootfiles>
            <rootfile full-path="OEBPS/content.opf" media-type="application/oebps-package+xml"/>
          </rootfiles>
        </container>
      </xsl:result-document>
      <xsl:if test="$verbose='true'">
        <xsl:message>write file OEBPS/content.opf</xsl:message>
      </xsl:if>
      <xsl:result-document href="{concat($directory,'/OEBPS/content.opf')}" method="xml">
        <package xmlns="http://www.idpf.org/2007/opf" unique-identifier="dcidid" version="2.0">
          <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:opf="http://www.idpf.org/2007/opf">
            <dc:title>
              <xsl:call-template name="generateSimpleTitle"/>
            </dc:title>
            <dc:language xsi:type="dcterms:RFC3066">
              <xsl:call-template name="generateLanguage"/>
            </dc:language>
            <xsl:call-template name="generateSubject"/>
            <dc:identifier id="dcidid" opf:scheme="URI">
              <xsl:call-template name="generateID"/>
            </dc:identifier>
            <xsl:variable name="A">
              <xsl:call-template name="generateAuthor"/>
            </xsl:variable>
            <dc:description>
              <xsl:call-template name="generateSimpleTitle"/>
              <xsl:text> / </xsl:text>
              <xsl:value-of select="$A"/>
            </dc:description>
            <dc:creator>
              <xsl:variable name="printA">
                <xsl:analyze-string select="$A" regex="([^,]+), ([^,]+), (.+)">
                  <xsl:matching-substring>
                    <xsl:value-of select="regex-group(1)"/>
                    <xsl:text>, </xsl:text>
                    <xsl:value-of select="regex-group(2)"/>
                  </xsl:matching-substring>
                  <xsl:non-matching-substring>
                    <xsl:value-of select="."/>
                  </xsl:non-matching-substring>
                </xsl:analyze-string>
              </xsl:variable>
              <xsl:choose>
                <xsl:when test="$printA=''">Anonymous/Unknown</xsl:when>
                <xsl:otherwise>
                  <xsl:value-of select="$printA"/>
                </xsl:otherwise>
              </xsl:choose>
            </dc:creator>
            <dc:publisher>
              <xsl:call-template name="generatePublisher"/>
            </dc:publisher>
            <xsl:for-each select="tei:teiHeader/tei:profileDesc/tei:creation/tei:date[@notAfter]">
              <dc:date opf:event="creation">
                <xsl:value-of select="@notAfter"/>
              </dc:date>
            </xsl:for-each>
            <xsl:for-each select="tei:teiHeader/tei:fileDesc/tei:sourceDesc//tei:date[@when][1]">
              <dc:date opf:event="original-publication">
                <xsl:value-of select="@when"/>
              </dc:date>
            </xsl:for-each>
            <dc:date opf:event="epub-publication" xsi:type="dcterms:W3CDTF">
              <xsl:call-template name="generateDate"/>
            </dc:date>
            <dc:rights>
              <xsl:call-template name="generateLicence"/>
            </dc:rights>
            <xsl:if test="not($coverImageOutside='')">
              <meta name="cover" content="cover-image"/>
            </xsl:if>
          </metadata>
          <manifest>
            <!-- deal with intricacies of overlay files -->
            <xsl:variable name="TL" select="key('Timeline',1)"/>
            <xsl:if test="$mediaoverlay='true' and        key('Timeline',1)">
              <xsl:if test="$verbose='true'">
                <xsl:message>write file SMIL files</xsl:message>
              </xsl:if>
              <xsl:for-each select="key('Timeline',1)">
                <xsl:variable name="TLnumber">
                  <xsl:number level="any"/>
                </xsl:variable>
                <xsl:variable name="audio">
                  <xsl:text>media/audio</xsl:text>
                  <xsl:number level="any"/>
                  <xsl:text>.</xsl:text>
                  <xsl:value-of select="tokenize(@corresp,'\.')[last()]"/>
                </xsl:variable>
                <item id="timeline-audio{$TLnumber}" href="{$audio}">
                  <xsl:attribute name="media-type">
                    <xsl:choose>
                      <xsl:when test="contains($audio,'.m4a')">audio/m4a</xsl:when>
                      <xsl:otherwise>audio/m4a</xsl:otherwise>
                    </xsl:choose>
                  </xsl:attribute>
                </item>
                <xsl:for-each select="key('PB',1)">
                  <xsl:variable name="page">
                    <xsl:value-of select="generate-id()"/>
                  </xsl:variable>
                  <xsl:variable name="target">
                    <xsl:apply-templates select="." mode="ident"/>
                  </xsl:variable>
                  <xsl:if test="count(key('objectOnPage',$page))>0">
                    <item id="{$target}-audio" href="{$target}-overlay.smil" media-type="application/smil+xml"/>
                    <xsl:result-document href="{concat($directory,'/OEBPS/',$target,'-overlay.smil')}" method="xml">
                      <smil xmlns="http://www.w3.org/ns/SMIL" version="3.0" profile="http://www.ipdf.org/epub/30/profile/content/">
                        <body>
                          <xsl:for-each select="key('objectOnPage',$page)">
                            <xsl:variable name="object" select="@xml:id"/>
                            <xsl:for-each select="$TL">
                              <xsl:for-each select="key('Object',$object)">
                                <par id="{@xml:id}">
                                  <text src="{$target}.html{@corresp}"/>
                                  <audio src="{$audio}" clipBegin="{@from}{../@unit}" clipEnd="{@to}{../@unit}"/>
                                </par>
                              </xsl:for-each>
                            </xsl:for-each>
                          </xsl:for-each>
                        </body>
                      </smil>
                    </xsl:result-document>
                  </xsl:if>
                </xsl:for-each>
              </xsl:for-each>
            </xsl:if>
            <xsl:if test="not($coverImageOutside='')">
              <item href="{$coverImageOutside}" id="cover-image" media-type="image/jpeg"/>
            </xsl:if>
            <xsl:if test="not($coverimage='') and not($coverimage=$coverImageOutside)">
              <item href="{$coverimage}" id="cover-image-extra" media-type="image/jpeg"/>
            </xsl:if>
            <xsl:for-each select="tokenize($javascriptFiles,',')">
              <xsl:variable name="name" select="tokenize(normalize-space(.),'/')[last()]"/>
              <item href="{$name}" id="javascript{position()}" media-type="text/javascript"/>
            </xsl:for-each>
            <item href="stylesheet.css" id="css" media-type="text/css"/>
            <item href="titlepage.html" id="titlepage" media-type="application/xhtml+xml"/>
            <xsl:if test="$filePerPage='true'">
              <item href="titlepageverso.html" id="titlepageverso" media-type="application/xhtml+xml"/>
            </xsl:if>
            <xsl:for-each select="tei:text/tei:front/tei:titlePage">
              <xsl:variable name="N" select="position()"/>
              <item href="titlepage{$N}.html" id="titlepage{$N}" media-type="application/xhtml+xml"/>
            </xsl:for-each>
            <item href="titlepageback.html" id="titlepageback" media-type="application/xhtml+xml"/>
            <item id="print.css" href="print.css" media-type="text/css"/>
            <item id="apt" href="page-template.xpgt" media-type="application/adobe-page-template+xml"/>
            <item id="start" href="index.html" media-type="application/xhtml+xml"/>
            <xsl:choose>
              <xsl:when test="$filePerPage='true'">
                <xsl:for-each select="key('PB',1)">
                  <xsl:variable name="target">
                    <xsl:apply-templates select="." mode="ident"/>
                  </xsl:variable>
                  <xsl:if test="@facs">
                    <xsl:variable name="facstarget">
                      <xsl:apply-templates select="." mode="ident"/>
                      <xsl:text>-facs.html</xsl:text>
                    </xsl:variable>
                    <item href="{$facstarget}" media-type="application/xhtml+xml">
                      <xsl:attribute name="id">
                        <xsl:text>pagefacs</xsl:text>
                        <xsl:number level="any"/>
                      </xsl:attribute>
                    </item>
                  </xsl:if>
                  <item href="{$target}.html" media-type="application/xhtml+xml">
                    <xsl:if test="$mediaoverlay='true'">
                      <xsl:attribute name="media-overlay">
                        <xsl:value-of select="$target"/>
                        <xsl:text>-audio</xsl:text>
                      </xsl:attribute>
                    </xsl:if>
                    <xsl:attribute name="id">
                      <xsl:text>page</xsl:text>
                      <xsl:number level="any"/>
                    </xsl:attribute>
                  </item>
                </xsl:for-each>
              </xsl:when>
              <xsl:otherwise>
                <xsl:for-each select="$TOC/html:TOC/html:ul/html:li">
                  <xsl:choose>
                    <xsl:when test="not(html:a)"/>
                    <xsl:when test="starts-with(html:a/@href,'#')"/>
                    <xsl:otherwise>
                      <item href="{html:a[1]/@href}" media-type="application/xhtml+xml">
                        <xsl:attribute name="id">
                          <xsl:text>section</xsl:text>
                          <xsl:number count="html:li" level="any"/>
                        </xsl:attribute>
                      </item>
                    </xsl:otherwise>
                  </xsl:choose>
                  <xsl:if test="html:ul">
                    <xsl:for-each select="html:ul//html:li[html:a          and          not(contains(html:a/@href,'#'))]">
                      <item href="{html:a[1]/@href}" media-type="application/xhtml+xml">
                        <xsl:attribute name="id">
                          <xsl:text>section</xsl:text>
                          <xsl:number count="html:li" level="any"/>
                        </xsl:attribute>
                      </item>
                    </xsl:for-each>
                  </xsl:if>
                </xsl:for-each>
              </xsl:otherwise>
            </xsl:choose>
            <!-- images -->
            <xsl:for-each select="key('GRAPHICS',1)">
              <xsl:variable name="img" select="@url|@facs"/>
              <xsl:if test="not($img=$coverImageOutside)">
                <xsl:variable name="ID">
                  <xsl:number level="any"/>
                </xsl:variable>
                <xsl:variable name="mimetype">
                  <xsl:choose>
                    <xsl:when test="@mimeType != ''">
                      <xsl:value-of select="@mimeType"/>
                    </xsl:when>
                    <xsl:when test="contains($img,'.gif')">image/gif</xsl:when>
                    <xsl:when test="contains($img,'.png')">image/png</xsl:when>
                    <xsl:when test="contains($img,'.mpeg')">video/mpeg4</xsl:when>
                    <xsl:when test="contains($img,'.mp4')">video/mpeg4</xsl:when>
                    <xsl:when test="contains($img,'.m4v')">video/mpeg4</xsl:when>
                    <xsl:otherwise>image/jpeg</xsl:otherwise>
                  </xsl:choose>
                </xsl:variable>
                <item href="{$img}" id="image-{$ID}" media-type="{$mimetype}"/>
              </xsl:if>
            </xsl:for-each>
            <!-- page images -->
            <xsl:for-each select="key('PBGRAPHICS',1)">
              <xsl:variable name="img" select="@facs"/>
              <xsl:variable name="ID">
                <xsl:number level="any"/>
              </xsl:variable>
              <xsl:variable name="mimetype">
                <xsl:choose>
                  <xsl:when test="@mimeType != ''">
                    <xsl:value-of select="@mimeType"/>
                  </xsl:when>
                  <xsl:when test="contains($img,'.gif')">image/gif</xsl:when>
                  <xsl:when test="contains($img,'.png')">image/png</xsl:when>
                  <xsl:otherwise>image/jpeg</xsl:otherwise>
                </xsl:choose>
              </xsl:variable>
              <item href="{$img}" id="pbimage-{$ID}" media-type="{$mimetype}"/>
            </xsl:for-each>
            <item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml"/>
            <xsl:call-template name="epubManifestHook"/>
          </manifest>
          <spine toc="ncx">
            <itemref idref="titlepage" linear="yes"/>
            <xsl:if test="$filePerPage='true'">
              <itemref idref="titlepageverso" linear="yes"/>
            </xsl:if>
            <xsl:for-each select="tei:text/tei:front/tei:titlePage">
              <xsl:variable name="N" select="position()"/>
              <itemref idref="titlepage{$N}" linear="yes"/>
            </xsl:for-each>
            <itemref idref="start" linear="yes"/>
            <xsl:choose>
              <xsl:when test="$filePerPage='true'">
                <xsl:for-each select="key('PB',1)">
                  <xsl:if test="@facs">
                    <itemref>
                      <xsl:attribute name="idref">
                        <xsl:text>pagefacs</xsl:text>
                        <xsl:number level="any"/>
                      </xsl:attribute>
                      <xsl:attribute name="linear">yes</xsl:attribute>
                    </itemref>
                  </xsl:if>
                  <itemref>
                    <xsl:attribute name="idref">
                      <xsl:text>page</xsl:text>
                      <xsl:number level="any"/>
                    </xsl:attribute>
                    <xsl:attribute name="linear">yes</xsl:attribute>
                  </itemref>
                </xsl:for-each>
              </xsl:when>
              <xsl:otherwise>
                <xsl:for-each select="$TOC/html:TOC/html:ul/html:li">
                  <xsl:choose>
                    <xsl:when test="not(html:a)"/>
                    <xsl:when test="starts-with(html:a/@href,'#')"/>
                    <xsl:otherwise>
                      <itemref>
                        <xsl:attribute name="idref">
                          <xsl:text>section</xsl:text>
                          <xsl:number count="html:li" level="any"/>
                        </xsl:attribute>
                        <xsl:attribute name="linear">yes</xsl:attribute>
                      </itemref>
                    </xsl:otherwise>
                  </xsl:choose>
                  <xsl:if test="html:ul">
                    <xsl:for-each select="html:ul//html:li[html:a and not(contains(html:a/@href,'#'))]">
                      <itemref>
                        <xsl:attribute name="idref">
                          <xsl:text>section</xsl:text>
                          <xsl:number count="html:li" level="any"/>
                        </xsl:attribute>
                        <xsl:attribute name="linear">yes</xsl:attribute>
                      </itemref>
                    </xsl:for-each>
                  </xsl:if>
                </xsl:for-each>
              </xsl:otherwise>
            </xsl:choose>
            <itemref idref="titlepageback">
              <xsl:attribute name="linear">
                <xsl:choose>
                  <xsl:when test="$filePerPage='true'">yes</xsl:when>
                  <xsl:otherwise>no</xsl:otherwise>
                </xsl:choose>
              </xsl:attribute>
            </itemref>
            <xsl:call-template name="epubSpineHook"/>
          </spine>
          <guide>
            <reference type="text" href="titlepage.html" title="Cover"/>
            <reference type="text" title="Start" href="index.html"/>
            <xsl:choose>
              <xsl:when test="$filePerPage='true'">
              </xsl:when>
              <xsl:otherwise>
                <xsl:for-each select="$TOC/html:TOC/html:ul/html:li">
                  <xsl:if test="html:a">
                    <reference type="text" href="{html:a[1]/@href}">
                      <xsl:attribute name="title">
                        <xsl:value-of select="normalize-space(html:a[1])"/>
                      </xsl:attribute>
                    </reference>
                  </xsl:if>
                  <xsl:if test="contains(parent::html:ul/@class,'group')">
                    <xsl:for-each select="html:ul//html:li">
                      <xsl:choose>
                        <xsl:when test="not(html:a)"/>
                        <xsl:when test="contains(html:a/@href,'#')"/>
                        <xsl:otherwise>
                          <reference type="text" href="{html:a/@href}">
                            <xsl:attribute name="title">
                              <xsl:value-of select="normalize-space(html:a[1])"/>
                            </xsl:attribute>
                          </reference>
                        </xsl:otherwise>
                      </xsl:choose>
                    </xsl:for-each>
                  </xsl:if>
                </xsl:for-each>
              </xsl:otherwise>
            </xsl:choose>
            <reference href="titlepageback.html" type="text" title="About this book"/>
          </guide>
        </package>
      </xsl:result-document>
      <xsl:if test="$verbose='true'">
        <xsl:message>write file OEBPS/titlepage.html</xsl:message>
      </xsl:if>
      <xsl:result-document href="{concat($directory,'/OEBPS/titlepage.html')}" method="xml">
        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
          <head>
            <xsl:call-template name="metaHTML">
              <xsl:with-param name="title">Title page</xsl:with-param>
            </xsl:call-template>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
            <meta name="calibre:cover" content="true"/>
            <title>Title page</title>
            <style type="text/css" title="override_css">
		@page {padding: 0pt; margin:0pt}
		body { text-align: center; padding:0pt; margin: 0pt; }
	      </style>
          </head>
          <body>
            <xsl:choose>
              <xsl:when test="$coverImageInside=''">
                <div>
                  <xsl:attribute name="style">
		      font-family: serif; 
		      height:860;          
		      font-size:30pt; 
		      font-weight: bold;
		      padding-top: 15pt;
		      margin: 12pt;
		      border: solid red 1pt; 
		      text-align:center;
		    </xsl:attribute>
                  <xsl:call-template name="generateTitle"/>
                </div>
              </xsl:when>
              <xsl:otherwise>
                <div>
                  <img width="1200" height="1700" alt="cover picture" src="{$coverImageInside}"/>
                </div>
              </xsl:otherwise>
            </xsl:choose>
          </body>
        </html>
      </xsl:result-document>
      <xsl:for-each select="tei:text/tei:front/tei:titlePage">
        <xsl:variable name="N" select="position()"/>
        <xsl:if test="$verbose='true'">
          <xsl:message>write file OEBPS/titlepage
            <xsl:value-of select="$N"/>.html</xsl:message>
        </xsl:if>
        <xsl:result-document href="{concat($directory,'/OEBPS/titlepage',$N,'.html')}" method="xml">
          <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
            <head>
              <xsl:call-template name="metaHTML">
                <xsl:with-param name="title">Title page</xsl:with-param>
              </xsl:call-template>
              <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
              <link href="stylesheet.css" rel="stylesheet" type="text/css"/>
              <title>Title page</title>
            </head>
            <body>
              <div class="titlePage">
                <xsl:apply-templates/>
              </div>
            </body>
          </html>
        </xsl:result-document>
      </xsl:for-each>
      <xsl:if test="$filePerPage='true'">
        <xsl:if test="$verbose='true'">
          <xsl:message>write file OEBPS/titlepageverso.html</xsl:message>
        </xsl:if>
        <xsl:result-document href="{concat($directory,'/OEBPS/titlepageverso.html')}" method="xml">
          <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
            <head>
              <xsl:call-template name="metaHTML">
                <xsl:with-param name="title">title page verso</xsl:with-param>
              </xsl:call-template>
              <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
              <title>title page verso</title>
            </head>
            <body>
              <p/>
            </body>
          </html>
        </xsl:result-document>
      </xsl:if>
      <xsl:if test="$verbose='true'">
        <xsl:message>write file OEBPS/titlepageback.html</xsl:message>
      </xsl:if>
      <xsl:result-document href="{concat($directory,'/OEBPS/titlepageback.html')}" method="xml">
        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
          <head>
            <xsl:call-template name="metaHTML">
              <xsl:with-param name="title">About this book</xsl:with-param>
            </xsl:call-template>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
            <title>About this book</title>
          </head>
          <body>
            <div style="text-align: left; font-size: larger">
              <h2>Information about this book</h2>
              <xsl:for-each select="/*/tei:teiHeader/tei:fileDesc">
                <xsl:apply-templates mode="metadata"/>
              </xsl:for-each>
              <xsl:for-each select="/*/tei:teiHeader/tei:encodingDesc">
                <xsl:apply-templates mode="metadata"/>
              </xsl:for-each>
            </div>
          </body>
        </html>
      </xsl:result-document>
      <xsl:if test="$verbose='true'">
        <xsl:message>write file OEBPS/toc.ncx</xsl:message>
      </xsl:if>
      <xsl:result-document href="{concat($directory,'/OEBPS/toc.ncx')}" method="xml">
        <ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1">
          <head>
            <meta name="dtb:uid">
              <xsl:attribute name="content">
                <xsl:call-template name="generateID"/>
              </xsl:attribute>
            </meta>
            <meta name="dtb:totalPageCount" content="0"/>
            <meta name="dtb:maxPageNumber" content="0"/>
          </head>
          <docTitle>
            <text>
              <xsl:call-template name="generateSimpleTitle"/>
            </text>
          </docTitle>
          <navMap>
            <xsl:variable name="navPoints">
              <navPoint>
                <navLabel>
                  <text>[Cover]</text>
                </navLabel>
                <content src="titlepage.html"/>
              </navPoint>
              <xsl:for-each select="tei:text/tei:front/tei:titlePage[1]">
                <xsl:variable name="N" select="position()"/>
                <navPoint>
                  <navLabel>
                    <text>[Title page]</text>
                  </navLabel>
                  <content src="titlepage{$N}.html"/>
                </navPoint>
              </xsl:for-each>
              <xsl:choose>
                <xsl:when test="not($TOC/html:TOC/html:ul[@class='toc toc_body']/html:li)">
                  <xsl:for-each select="$TOC/html:TOC/html:ul[@class='toc toc_front']">
                    <xsl:apply-templates select="html:li"/>
                  </xsl:for-each>
                  <navPoint>
                    <navLabel>
                      <text>[The book]</text>
                    </navLabel>
                    <content src="index.html"/>
                  </navPoint>
                  <xsl:for-each select="$TOC/html:TOC/html:ul[contains(@class,'group')]">
                    <xsl:apply-templates select=".//html:li[not(contains(html:a/@href,'#'))]"/>
                  </xsl:for-each>
                  <xsl:for-each select="$TOC/html:TOC/html:ul[@class='toc toc_back']">
                    <xsl:apply-templates select="html:li"/>
                  </xsl:for-each>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:for-each select="$TOC/html:TOC/html:ul">
                    <xsl:apply-templates select="html:li"/>
                  </xsl:for-each>
                </xsl:otherwise>
              </xsl:choose>
              <navPoint>
                <navLabel>
                  <text>[About this book]</text>
                </navLabel>
                <content src="titlepageback.html"/>
              </navPoint>
            </xsl:variable>
            <xsl:for-each select="$navPoints/ncx:navPoint">
              <xsl:variable name="pos" select="position()"/>
              <navPoint id="navPoint-{$pos}" playOrder="{$pos}">
                <xsl:copy-of select="*"/>
              </navPoint>
            </xsl:for-each>
          </navMap>
        </ncx>
      </xsl:result-document>
      <xsl:if test="$verbose='true'">
        <xsl:message>write file OEBPS/page-template.xpgt</xsl:message>
      </xsl:if>
      <xsl:result-document method="xml" href="{concat($directory,'/OEBPS/page-template.xpgt')}">
        <ade:template xmlns="http://www.w3.org/1999/xhtml" xmlns:ade="http://ns.adobe.com/2006/ade" xmlns:fo="http://www.w3.org/1999/XSL/Format">
          <fo:layout-master-set>
            <fo:simple-page-master master-name="single_column">
              <fo:region-body margin-bottom="3pt" margin-top="0.5em" margin-left="3pt" margin-right="3pt"/>
            </fo:simple-page-master>
            <fo:simple-page-master master-name="single_column_head">
              <fo:region-before extent="8.3em"/>
              <fo:region-body margin-bottom="3pt" margin-top="6em" margin-left="3pt" margin-right="3pt"/>
            </fo:simple-page-master>
            <fo:simple-page-master master-name="two_column" margin-bottom="0.5em" margin-top="0.5em" margin-left="0.5em" margin-right="0.5em">
              <fo:region-body column-count="2" column-gap="10pt"/>
            </fo:simple-page-master>
            <fo:simple-page-master master-name="two_column_head" margin-bottom="0.5em" margin-left="0.5em" margin-right="0.5em">
              <fo:region-before extent="8.3em"/>
              <fo:region-body column-count="2" margin-top="6em" column-gap="10pt"/>
            </fo:simple-page-master>
            <fo:simple-page-master master-name="three_column" margin-bottom="0.5em" margin-top="0.5em" margin-left="0.5em" margin-right="0.5em">
              <fo:region-body column-count="3" column-gap="10pt"/>
            </fo:simple-page-master>
            <fo:simple-page-master master-name="three_column_head" margin-bottom="0.5em" margin-top="0.5em" margin-left="0.5em" margin-right="0.5em">
              <fo:region-before extent="8.3em"/>
              <fo:region-body column-count="3" margin-top="6em" column-gap="10pt"/>
            </fo:simple-page-master>
            <fo:page-sequence-master>
              <fo:repeatable-page-master-alternatives>
                <fo:conditional-page-master-reference master-reference="three_column_head" page-position="first" ade:min-page-width="80em"/>
                <fo:conditional-page-master-reference master-reference="three_column" ade:min-page-width="80em"/>
                <fo:conditional-page-master-reference master-reference="two_column_head" page-position="first" ade:min-page-width="50em"/>
                <fo:conditional-page-master-reference master-reference="two_column" ade:min-page-width="50em"/>
                <fo:conditional-page-master-reference master-reference="single_column_head" page-position="first"/>
                <fo:conditional-page-master-reference master-reference="single_column"/>
              </fo:repeatable-page-master-alternatives>
            </fo:page-sequence-master>
          </fo:layout-master-set>
          <ade:style>
            <ade:styling-rule selector=".title_box" display="adobe-other-region" adobe-region="xsl-region-before"/>
          </ade:style>
        </ade:template>
      </xsl:result-document>
      <xsl:if test="$filePerPage='true'">
        <xsl:if test="$verbose='true'">
          <xsl:message>write file META-INF/com.apple.ibooks.display-options.xml</xsl:message>
        </xsl:if>
        <xsl:result-document href="{concat($directory,'/META-INF/com.apple.ibooks.display-options.xml')}">
          <display_options xmlns="">
            <platform name="*">
              <option name="fixed-layout">true</option>
            </platform>
          </display_options>
        </xsl:result-document>
      </xsl:if>
    </xsl:for-each>
  </xsl:for-each>
</xsl:template>
Stylesheet location ../../../epub/tei-to-epub.xsl
Template html:li
Namespace No namespace
Match html:li
Mode #default
Import precedence 6
Source
<xsl:template match="html:li">
  <xsl:choose>
    <xsl:when test="not(html:a)"/>
    <xsl:when test="starts-with(html:a/@href,'#')"/>
    <xsl:when test="contains(@class,'headless')"/>
    <xsl:when test="html:a/@href=preceding-sibling::html:li/html:a/@href"/>
    <xsl:otherwise>
      <navPoint xmlns="http://www.daisy.org/z3986/2005/ncx/">
        <navLabel>
          <text>
            <xsl:value-of select="html:span[@class='headingNumber']"/>
            <xsl:value-of select="normalize-space(html:a[1])"/>
          </text>
        </navLabel>
        <content src="{html:a/@href}"/>
      </navPoint>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>
Stylesheet location ../../../epub/tei-to-epub.xsl
Template javascriptHook
Namespace No namespace
Used by
References
Parameter javascriptFiles
Supersedes
Template javascriptHook
Import precedence 6
Source
<xsl:template name="javascriptHook">
  <xsl:for-each select="tokenize($javascriptFiles,',')">
    <xsl:variable name="name" select="tokenize(normalize-space(.),'/')[last()]"/>
    <script type="text/javascript" src="{$name}">
      <xsl:comment>JS library</xsl:comment>
    </script>
  </xsl:for-each>
</xsl:template>
Stylesheet location ../../../epub/tei-to-epub.xsl
Template epubSpineHook
Namespace No namespace
Used by
Template processTEI
Import precedence 6
Source
<xsl:template name="epubSpineHook"/>
Stylesheet location ../../../epub/tei-to-epub.xsl
Template epubManifestHook
Namespace No namespace
Used by
Template processTEI
Import precedence 6
Source
<xsl:template name="epubManifestHook"/>
Stylesheet location ../../../epub/tei-to-epub.xsl
Template processTEIHook
Namespace No namespace
Used by
Template processTEI
Import precedence 6
Source
<xsl:template name="processTEIHook"/>
Stylesheet location ../../../epub/tei-to-epub.xsl
Parameter STDOUT
Namespace No namespace
Used by
Supersedes
Parameter STDOUT
Source
<xsl:param name="STDOUT">false</xsl:param>
Stylesheet location ../../../epub/tei-to-epub.xsl
Parameter autoHead
Namespace No namespace
Used by
Supersedes
Parameter autoHead
Source
<xsl:param name="autoHead">true</xsl:param>
Stylesheet location ../../../epub/tei-to-epub.xsl
Parameter autoToc
Namespace No namespace
Used by
Supersedes
Parameter autoToc
Source
<xsl:param name="autoToc">true</xsl:param>
Stylesheet location ../../../epub/tei-to-epub.xsl
Parameter bottomNavigationPanel
Namespace No namespace
Used by
Supersedes
Source
<xsl:param name="bottomNavigationPanel">false</xsl:param>
Stylesheet location ../../../epub/tei-to-epub.xsl
Parameter coverimage
Namespace No namespace
Used by
Template processTEI
Source
<xsl:param name="coverimage"/>
Stylesheet location ../../../epub/tei-to-epub.xsl
Parameter createanttask
Namespace No namespace
Source
<xsl:param name="createanttask">false</xsl:param>
Stylesheet location ../../../epub/tei-to-epub.xsl
Parameter cssFile
Namespace No namespace
Used by
Supersedes
Parameter cssFile
Source
<xsl:param name="cssFile">../tei.css</xsl:param>
Stylesheet location ../../../epub/tei-to-epub.xsl
Parameter cssODDFile
Namespace No namespace
Used by
Template processTEI
Source
<xsl:param name="cssODDFile">../odd.css</xsl:param>
Stylesheet location ../../../epub/tei-to-epub.xsl
Parameter cssPrintFile
Namespace No namespace
Used by
Supersedes
Parameter cssPrintFile
Source
<xsl:param name="cssPrintFile">../epub-print.css</xsl:param>
Stylesheet location ../../../epub/tei-to-epub.xsl
Parameter debug
Namespace No namespace
Source
<xsl:param name="debug">false</xsl:param>
Stylesheet location ../../../epub/tei-to-epub.xsl
Parameter directory
Namespace No namespace
Used by
Template processTEI
Parameter outputDir
Source
<xsl:param name="directory">.</xsl:param>
Stylesheet location ../../../epub/tei-to-epub.xsl
Parameter doctypePublic
Namespace No namespace
Used by
Supersedes
Parameter doctypePublic
Source
<xsl:param name="doctypePublic">-//W3C//DTD XHTML 1.1//EN</xsl:param>
Stylesheet location ../../../epub/tei-to-epub.xsl
Parameter doctypeSystem
Namespace No namespace
Used by
Supersedes
Parameter doctypeSystem
Source
<xsl:param name="doctypeSystem">http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd</xsl:param>
Stylesheet location ../../../epub/tei-to-epub.xsl
Parameter fixgraphicsurl
Namespace No namespace
Used by
Source
<xsl:param name="fixgraphicsurl">false</xsl:param>
Stylesheet location ../../../epub/tei-to-epub.xsl
Parameter footnoteBackLink
Namespace No namespace
Used by
Supersedes
Source
Stylesheet location ../../../epub/tei-to-epub.xsl
Parameter inputDir
Namespace No namespace
Source
<xsl:param name="inputDir">.</xsl:param>
Stylesheet location ../../../epub/tei-to-epub.xsl
Parameter institution
Namespace No namespace
Used by
Template stdheader
Supersedes
Parameter institution
Source
<xsl:param name="institution"/>
Stylesheet location ../../../epub/tei-to-epub.xsl
Parameter linkPanel
Namespace No namespace
Used by
Template stdfooter
Supersedes
Parameter linkPanel
Source
<xsl:param name="linkPanel">false</xsl:param>
Stylesheet location ../../../epub/tei-to-epub.xsl
Parameter odd
Namespace No namespace
Used by
Template processTEI
Source
<xsl:param name="odd">false</xsl:param>
Stylesheet location ../../../epub/tei-to-epub.xsl
Parameter outputDir
Namespace No namespace
Used by
Template outputChunkName
References
Parameter directory
Supersedes
Parameter outputDir
Source
<xsl:param name="outputDir">
  <xsl:value-of select="$directory"/>/OEBPS</xsl:param>
Stylesheet location ../../../epub/tei-to-epub.xsl
Parameter outputTarget
Namespace No namespace
Used by
Supersedes
Parameter outputTarget
Source
<xsl:param name="outputTarget">epub</xsl:param>
Stylesheet location ../../../epub/tei-to-epub.xsl
Parameter publisher
Namespace No namespace
Used by
Source
<xsl:param name="publisher"/>
Stylesheet location ../../../epub/tei-to-epub.xsl
Parameter splitLevel
Namespace No namespace
Used by
Supersedes
Parameter splitLevel
Source
<xsl:param name="splitLevel">0</xsl:param>
Stylesheet location ../../../epub/tei-to-epub.xsl
Parameter subject
Namespace No namespace
Used by
Template generateSubject
Source
<xsl:param name="subject"/>
Stylesheet location ../../../epub/tei-to-epub.xsl
Parameter tocDepth
Namespace No namespace
Used by
Template tei:*maketoc
Supersedes
Parameter tocDepth
Source
<xsl:param name="tocDepth">5</xsl:param>
Stylesheet location ../../../epub/tei-to-epub.xsl
Parameter tocFront
Namespace No namespace
Used by
Template mainTOC
Supersedes
Parameter tocFront
Source
<xsl:param name="tocFront">true</xsl:param>
Stylesheet location ../../../epub/tei-to-epub.xsl
Parameter topNavigationPanel
Namespace No namespace
Used by
Supersedes
Parameter topNavigationPanel
Source
<xsl:param name="topNavigationPanel">false</xsl:param>
Stylesheet location ../../../epub/tei-to-epub.xsl
Parameter uid
Namespace No namespace
Used by
Template generateID
Source
<xsl:param name="uid"/>
Stylesheet location ../../../epub/tei-to-epub.xsl
Parameter useHeaderFrontMatter
Namespace No namespace
Used by
Supersedes
Source
<xsl:param name="useHeaderFrontMatter">false</xsl:param>
Stylesheet location ../../../epub/tei-to-epub.xsl
Output (default)
Namespace No namespace
Output properties
method encoding indent
xml no
Source
<xsl:output method="xml" encoding="utf-8" indent="no"/>
Stylesheet location ../../../epub/tei-to-epub.xsl
Key Timeline
Namespace No namespace
Match tei:timeline
Use 1
Used by
Template processTEI
Source
<xsl:key name="Timeline" match="tei:timeline" use="1"/>
Stylesheet location ../../../epub/tei-to-epub.xsl
Key Object
Namespace No namespace
Match tei:when
Use substring(@corresp,2)
Used by
Template processTEI
Source
<xsl:key name="Object" match="tei:when" use="substring(@corresp,2)"/>
Stylesheet location ../../../epub/tei-to-epub.xsl
Key objectOnPage
Namespace No namespace
Match tei:*[@xml:id]
Use generate-id(preceding::tei:pb[1])
Used by
Template processTEI
Source
<xsl:key name="objectOnPage" match="tei:*[@xml:id]" use="generate-id(preceding::tei:pb[1])"/>
Stylesheet location ../../../epub/tei-to-epub.xsl