TEI stylesheet dealing with elements from the textstructure
module, making HTML output.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version. This library is
distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details. You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA xs
<xsl:template match="/"><xsl:if test="contains($processor,'Clark')"><xsl:message terminate="yes">XT is not supported by the TEI stylesheets,
as it does not implement the "key" function</xsl:message></xsl:if><xsl:call-template name="processTEI"/></xsl:template>
<xsl:template name="processTEI"><xsl:choose><!-- there are various choices of how to proceed, driven by
$pageLayout: Simple, CSS, Table, Frames
$STDOUT: true or false
$splitLevel: -1 to 3
$requestedID: requests a particular page
--><!-- we are making a composite layout and there is a TEI or teiCorpus element --><xsl:when test="($pageLayout = 'CSS' or $pageLayout = 'Table') and (tei:TEI or tei:teiCorpus)"><xsl:if test="$verbose='true'"><xsl:message>case 1: pageLayout<xsl:value-of select="$pageLayout"/></xsl:message></xsl:if><xsl:for-each select="tei:TEI|tei:teiCorpus"><xsl:call-template name="doPageTable"><xsl:with-param name="currentID" select="$requestedID"/></xsl:call-template></xsl:for-each><xsl:if test="$STDOUT='false'"><xsl:call-template name="doDivs"/></xsl:if></xsl:when><!-- we are making a frame-based system --><xsl:when test="$pageLayout='Frames'"><xsl:if test="$verbose='true'"><xsl:message>case 2: pageLayout<xsl:value-of select="$pageLayout"/></xsl:message></xsl:if><xsl:call-template name="doFrames"/></xsl:when><!-- we have been asked for a particular section of the document --><xsl:when test="not($requestedID='')"><xsl:if test="$verbose='true'"><xsl:message>case 3: ID<xsl:value-of select="$requestedID"/>, pageLayout<xsl:value-of select="$pageLayout"/></xsl:message></xsl:if><xsl:choose><xsl:when test="$requestedID='frametoc___'"><xsl:call-template name="writeFrameToc"/></xsl:when><xsl:when test="$requestedID='prelim___'"><xsl:apply-templates/></xsl:when><xsl:when test="count(key('IDS',$requestedID))>0"><xsl:for-each select="key('IDS',$requestedID)"><xsl:call-template name="writeDiv"/></xsl:for-each></xsl:when><xsl:otherwise><!-- the passed ID is a pseudo-XPath expression
which starts below TEI/text.
The real XPath syntax is changed to avoid problems
--><xsl:apply-templates mode="xpath" select="tei:TEI/tei:text"><xsl:with-param name="xpath" select="$requestedID"/></xsl:apply-templates></xsl:otherwise></xsl:choose></xsl:when><!-- we want HTML to just splurge out--><xsl:when test="$STDOUT='true'"><xsl:if test="$verbose='true'"><xsl:message>case 4: write to stdout, pageLayout<xsl:value-of select="$pageLayout"/></xsl:message></xsl:if><xsl:apply-templates/></xsl:when><!-- we want the document split up into separate files --><xsl:when test="tei:TEI or tei:teiCorpus and number($splitLevel)>-1"><xsl:if test="$verbose='true'"><xsl:message>case 5: split output,<xsl:value-of select="$splitLevel"/>pageLayout<xsl:value-of select="$pageLayout"/></xsl:message></xsl:if><xsl:apply-templates mode="split"/></xsl:when><!-- we want the whole document, in an output file --><xsl:otherwise><xsl:if test="$verbose='true'"><xsl:message>case 6: one document, pageLayout<xsl:value-of select="$pageLayout"/></xsl:message></xsl:if><xsl:choose><xsl:when test="$masterFile='' or $STDOUT='true'"><xsl:apply-templates/></xsl:when><xsl:otherwise><xsl:variable name="outName"><xsl:call-template name="outputChunkName"><xsl:with-param name="ident"><xsl:value-of select="$masterFile"/></xsl:with-param></xsl:call-template></xsl:variable><xsl:if test="$verbose='true'"><xsl:message>Opening file<xsl:value-of select="$outName"/></xsl:message></xsl:if><xsl:result-document doctype-public="{$doctypePublic}" doctype-system="{$doctypeSystem}" encoding="{$outputEncoding}" href="{$outName}" method="{$outputMethod}"><xsl:apply-templates/></xsl:result-document><xsl:if test="$verbose='true'"><xsl:message>Closing file<xsl:value-of select="$outName"/></xsl:message></xsl:if></xsl:otherwise></xsl:choose></xsl:otherwise></xsl:choose></xsl:template>
<xsl:template match="tei:*" mode="xpath"><xsl:param name="xpath"/><xsl:param name="action"/><xsl:choose><!-- if there is a path --><xsl:when test="$xpath"><!-- step is the part before the '_' (if there is one) --><xsl:variable name="step"><xsl:choose><xsl:when test="contains($xpath, '_')"><xsl:value-of select="substring-before($xpath, '_')"/></xsl:when><xsl:otherwise><xsl:value-of select="$xpath"/></xsl:otherwise></xsl:choose></xsl:variable><!-- the child's name is the part before the '.' --><xsl:variable name="childName" select="substring-before($step, '.')"/><!-- and its index is the part after '.' --><xsl:variable name="childIndex" select="substring-after($step, '.')"/><!-- so apply templates to that child, passing in the $xpath
left after the first step --><xsl:apply-templates mode="xpath" select="*[name() = $childName] [number($childIndex)]"><xsl:with-param name="xpath" select="substring-after($xpath, '_')"/><xsl:with-param name="action" select="$action"/></xsl:apply-templates></xsl:when><!-- if there's no path left, then this is the element we want --><xsl:otherwise><xsl:choose><xsl:when test="$action='header'"><xsl:apply-templates mode="xref" select="."/></xsl:when><xsl:when test="$action='notes'"><xsl:call-template name="printNotes"/></xsl:when><xsl:when test="$action='toclist'"><xsl:call-template name="linkListContents"><xsl:with-param name="style" select="'toclist'"/></xsl:call-template></xsl:when><xsl:when test="starts-with(local-name(),'div') and $pageLayout='Table' or $pageLayout='CSS'"><h2><xsl:apply-templates mode="xref" select="."/><xsl:call-template name="sectionHeadHook"/></h2><xsl:if test="$topNavigationPanel='true'"><xsl:call-template name="xrefpanel"><xsl:with-param name="homepage" select="concat($masterFile,$standardSuffix)"/><xsl:with-param name="mode" select="local-name(.)"/></xsl:call-template></xsl:if><xsl:call-template name="doDivBody"/><xsl:if test="$bottomNavigationPanel='true'"><xsl:call-template name="xrefpanel"><xsl:with-param name="homepage" select="concat($masterFile,$standardSuffix)"/><xsl:with-param name="mode" select="local-name(.)"/></xsl:call-template></xsl:if></xsl:when><xsl:when test="self::tei:divGen[@type='summary']"><xsl:call-template name="summaryToc"/></xsl:when><xsl:otherwise><html><xsl:call-template name="addLangAtt"/><xsl:call-template name="htmlFileTop"/><body id="TOP"><xsl:call-template name="bodyHook"/><xsl:call-template name="bodyJavascriptHook"/><div class="stdheader"><xsl:call-template name="stdheader"><xsl:with-param name="title"><xsl:call-template name="generateTitle"/></xsl:with-param></xsl:call-template></div><h2><xsl:apply-templates mode="xref" select="."/><xsl:call-template name="sectionHeadHook"/></h2><xsl:apply-templates/><xsl:call-template name="printNotes"/><xsl:call-template name="htmlFileBottom"/><xsl:call-template name="bodyEndHook"/></body></html></xsl:otherwise></xsl:choose></xsl:otherwise></xsl:choose></xsl:template>
<xsl:template match="tei:div|tei:div1|tei:div2|tei:div3|tei:div4|tei:div5|tei:div6"><xsl:variable name="depth"><xsl:apply-templates mode="depth" select="."/></xsl:variable><!-- depending on depth and splitting level,
we may do one of two things: --><xsl:choose><!-- -1. Override at top level --><xsl:when test="ancestor::tei:floatingText"><div><xsl:call-template name="divClassAttribute"><xsl:with-param name="depth" select="$depth"/></xsl:call-template><xsl:call-template name="doDivBody"><xsl:with-param name="Depth" select="$depth"/></xsl:call-template></div></xsl:when><xsl:when test="ancestor::tei:TEI/@rend='all'"><div><xsl:call-template name="divClassAttribute"><xsl:with-param name="depth" select="$depth"/></xsl:call-template><xsl:call-template name="doDivBody"><xsl:with-param name="Depth" select="$depth"/></xsl:call-template></div></xsl:when><xsl:when test="ancestor::tei:TEI/@rend='frontpage'"><div><xsl:call-template name="divClassAttribute"><xsl:with-param name="depth" select="$depth"/></xsl:call-template><xsl:call-template name="doDivBody"><xsl:with-param name="Depth" select="$depth"/></xsl:call-template></div></xsl:when><!--
<xsl:when test="ancestor::tei:text/parent::tei:group">
<div>
<xsl:call-template name="divClassAttribute">
<xsl:with-param name="depth" select="$depth"/>
</xsl:call-template>
<xsl:call-template name="doDivBody">
<xsl:with-param name="Depth" select="$depth"/>
</xsl:call-template>
</div>
</xsl:when>
--><!-- 0. We have gone far enough --><xsl:when test="$depth = $splitLevel and $STDOUT='true'"><xsl:if test="$virtualPages='true'"><xsl:call-template name="makeDivPage"><xsl:with-param name="depth" select="$depth"/></xsl:call-template></xsl:if></xsl:when><!-- 1. our section depth is below the splitting level --><xsl:when test="number($depth) > number($splitLevel) or @rend='nosplit' or ancestor::tei:TEI/@rend='all' or ancestor::tei:TEI/@rend='frontpage' or ancestor::tei:TEI/@rend='nosplit'"><div><xsl:call-template name="divClassAttribute"><xsl:with-param name="depth" select="$depth"/></xsl:call-template><xsl:call-template name="doDivBody"><xsl:with-param name="Depth" select="$depth"/></xsl:call-template></div></xsl:when><!-- 2. we are at or above splitting level,
so start a new page --><xsl:when test="number($depth) <= number($splitLevel) and ancestor::tei:front and $splitFrontmatter='true'"><xsl:call-template name="makeDivPage"><xsl:with-param name="depth" select="$depth"/></xsl:call-template></xsl:when><xsl:when test="number($depth) <= number($splitLevel) and ancestor::tei:back and $splitBackmatter='true'"><xsl:call-template name="makeDivPage"><xsl:with-param name="depth" select="$depth"/></xsl:call-template></xsl:when><xsl:when test="number($depth) <= number($splitLevel) and ancestor::tei:body"><xsl:call-template name="makeDivPage"><xsl:with-param name="depth" select="$depth"/></xsl:call-template></xsl:when><xsl:otherwise><div><xsl:call-template name="divClassAttribute"><xsl:with-param name="depth" select="$depth"/></xsl:call-template><xsl:call-template name="doDivBody"><xsl:with-param name="Depth" select="$depth"/></xsl:call-template></div></xsl:otherwise></xsl:choose></xsl:template>
<xsl:template name="htmlFileTop"><xsl:comment>THIS FILE IS GENERATED FROM AN XML MASTER. DO NOT EDIT (6)</xsl:comment><xsl:variable name="pagetitle"><xsl:call-template name="generateTitle"/></xsl:variable><head><title><xsl:value-of select="$pagetitle"/></title><xsl:call-template name="headHook"/><xsl:call-template name="metaHTML"><xsl:with-param name="title" select="$pagetitle"/></xsl:call-template><xsl:call-template name="includeCSS"/><xsl:call-template name="cssHook"/><xsl:call-template name="includeJavascript"/><xsl:call-template name="javascriptHook"/></head></xsl:template>
<xsl:template name="mainFrame"><xsl:param name="currentID"/><xsl:param name="minimal">false</xsl:param><xsl:choose><xsl:when test="$currentID='current'"><xsl:apply-templates/></xsl:when><xsl:when test="$currentID='' and number($splitLevel)=-1"><xsl:apply-templates/></xsl:when><xsl:when test="$currentID='' and $virtualPages='true'"><xsl:apply-templates/></xsl:when><xsl:when test="self::teiCorpus.2"><xsl:call-template name="corpusBody"/></xsl:when><xsl:when test="$currentID=''"><!-- we need to locate the first interesting object in the file, ie
the first grandchild of <text > --><xsl:for-each select=" descendant-or-self::tei:TEI/tei:text/tei:*[1]/*[1]"><xsl:apply-templates mode="paging" select="."/><xsl:if test="$autoToc='true'"><xsl:if test="following-sibling::tei:div/tei:head"><xsl:call-template name="contentsHeading"/><ul class="toc"><xsl:apply-templates mode="maketoc" select="following-sibling::tei:div"><xsl:with-param name="forcedepth" select="'0'"/></xsl:apply-templates></ul></xsl:if></xsl:if></xsl:for-each></xsl:when><xsl:otherwise><xsl:choose><xsl:when test="count(key('IDS',$currentID))>0"><xsl:for-each select="key('IDS',$currentID)"><h2><xsl:apply-templates mode="xref" select="."/><xsl:call-template name="sectionHeadHook"/></h2><xsl:if test="$topNavigationPanel='true'"><xsl:call-template name="xrefpanel"><xsl:with-param name="homepage" select="concat($masterFile,$standardSuffix)"/><xsl:with-param name="mode" select="local-name(.)"/></xsl:call-template></xsl:if><xsl:call-template name="doDivBody"/><xsl:if test="$bottomNavigationPanel='true'"><xsl:call-template name="xrefpanel"><xsl:with-param name="homepage" select="concat($masterFile,$standardSuffix)"/><xsl:with-param name="mode" select="local-name(.)"/></xsl:call-template></xsl:if></xsl:for-each></xsl:when><xsl:otherwise><!-- the passed ID is a pseudo-XPath expression
which starts below TEI/tei:text.
The real XPath syntax is changed to avoid problems
--><xsl:choose><xsl:when test="ancestor-or-self::tei:TEI/tei:group/tei:text"><xsl:apply-templates mode="xpath" select="ancestor-or-self::tei:TEI/tei:group/tei:text"><xsl:with-param name="xpath" select="$currentID"/></xsl:apply-templates></xsl:when><xsl:otherwise><xsl:apply-templates mode="xpath" select="ancestor-or-self::tei:TEI/tei:text"><xsl:with-param name="xpath" select="$currentID"/></xsl:apply-templates></xsl:otherwise></xsl:choose></xsl:otherwise></xsl:choose></xsl:otherwise></xsl:choose><xsl:call-template name="partialFootNotes"><xsl:with-param name="currentID" select="$currentID"/></xsl:call-template><xsl:if test="$minimal='false'"><xsl:call-template name="stdfooter"/></xsl:if></xsl:template>
<xsl:template name="nextLink"><xsl:variable name="myName"><xsl:value-of select="local-name(.)"/></xsl:variable><xsl:choose><xsl:when test="following-sibling::tei:TEI"><xsl:apply-templates mode="generateNextLink" select="following-sibling::tei:TEI[1]"/></xsl:when><xsl:when test="following-sibling::tei:div[tei:head or $autoHead='true']"><xsl:apply-templates mode="generateNextLink" select="following-sibling::tei:div[1]"/></xsl:when><xsl:when test="parent::tei:body/following-sibling::tei:back/tei:div[tei:head or $autoHead='true']"><xsl:apply-templates mode="generateNextLink" select="parent::tei:body/following-sibling::tei:back/tei:div[1]"/></xsl:when><xsl:when test="parent::tei:front/following-sibling::tei:body/tei:div[tei:head or $autoHead='true']"><xsl:apply-templates mode="generateNextLink" select="parent::tei:front/following-sibling::tei:body/tei:div[1]"/></xsl:when><xsl:when test="$myName='div1' and following-sibling::tei:div1[tei:head or $autoHead='true']"><xsl:apply-templates mode="generateNextLink" select="following-sibling::tei:div1[1]"/></xsl:when><xsl:when test="$myName='div2' and following-sibling::tei:div2[tei:head or $autoHead='true']"><xsl:apply-templates mode="generateNextLink" select="following-sibling::tei:div2[1]"/></xsl:when><xsl:when test="$myName='div3' and following-sibling::tei:div3[tei:head or $autoHead='true']"><xsl:apply-templates mode="generateNextLink" select="following-sibling::tei:div3[1]"/></xsl:when></xsl:choose></xsl:template>
<xsl:template name="previousLink"><xsl:variable name="myName"><xsl:value-of select="local-name(.)"/></xsl:variable><xsl:choose><xsl:when test="preceding-sibling::tei:TEI"><xsl:apply-templates mode="generatePreviousLink" select="preceding-sibling::tei:TEI[1]"/></xsl:when><xsl:when test="preceding-sibling::tei:div[tei:head or $autoHead='true']"><xsl:apply-templates mode="generatePreviousLink" select="preceding-sibling::tei:div[1]"/></xsl:when><xsl:when test="parent::tei:body/preceding-sibling::tei:front/tei:div[tei:head or $autoHead='true']"><xsl:apply-templates mode="generatePreviousLink" select="parent::tei:body/preceding-sibling::tei:front/tei:div[last()]"/></xsl:when><xsl:when test="parent::tei:back/preceding-sibling::tei:body/tei:div[tei:head or $autoHead='true']"><xsl:apply-templates mode="generatePreviousLink" select="parent::tei:body/preceding-sibling::tei:body/tei:div[last()]"/></xsl:when><xsl:when test="$myName='div1' and preceding-sibling::tei:div1[tei:head or $autoHead='true']"><xsl:apply-templates mode="generatePreviousLink" select="preceding-sibling::tei:div1[1]"/></xsl:when><xsl:when test="$myName='div2' and preceding-sibling::tei:div2[tei:head or $autoHead='true']"><xsl:apply-templates mode="generatePreviousLink" select="preceding-sibling::tei:div2[1]"/></xsl:when><xsl:when test="$myName='div3' and preceding-sibling::tei:div3[tei:head or $autoHead='true']"><xsl:apply-templates mode="generatePreviousLink" select="preceding-sibling::tei:div3[1]"/></xsl:when></xsl:choose></xsl:template>
<xsl:template name="simpleBody"><!-- front matter --><xsl:apply-templates select="tei:text/tei:front"/><xsl:if test="$autoToc='true' and (descendant::tei:div or descendant::tei:div1) and not(descendant::tei:divGen[@type='toc'])"><h2><xsl:call-template name="i18n"><xsl:with-param name="word">tocWords</xsl:with-param></xsl:call-template></h2><xsl:call-template name="mainTOC"/></xsl:if><!-- main text --><xsl:choose><xsl:when test="tei:text/tei:group"><xsl:apply-templates select="tei:text/tei:group"/></xsl:when><xsl:otherwise><xsl:apply-templates select="tei:text/tei:body"/></xsl:otherwise></xsl:choose><!-- back matter --><xsl:apply-templates select="tei:text/tei:back"/><xsl:call-template name="printNotes"/></xsl:template>
<xsl:template name="summaryToc"><div class="teidiv"><p>Select headings on the left-hand side to see more explanation of the
links on the right.</p><table cellspacing="7"><thead><tr><th nowrap="nowrap"/><th/></tr></thead><tbody><xsl:for-each select="//tei:body/tei:div"><xsl:text></xsl:text><tr class="summaryline"><td align="right" class="summarycell" valign="top"><b><a class="nolink"><xsl:attribute name="href"><xsl:apply-templates mode="generateLink" select="."/></xsl:attribute><xsl:value-of select="tei:head"/></a></b></td><td class="link" valign="top"><xsl:for-each select=".//xref|.//xptr"><xsl:if test="position() > 1"><xsl:text></xsl:text><img alt="*" src="/images/dbluball.gif"/><xsl:text></xsl:text></xsl:if><span class="nowrap"><xsl:apply-templates select="."/></span></xsl:for-each></td></tr></xsl:for-each></tbody></table></div></xsl:template>
<xsl:template name="writeFrameToc"><html><xsl:call-template name="addLangAtt"/><xsl:comment>THIS FILE IS GENERATED FROM AN XML MASTER. DO NOT EDIT (3)</xsl:comment><head><title><xsl:call-template name="generateTitle"/></title><xsl:call-template name="includeCSS"/><xsl:call-template name="cssHook"/><base target="framemain"/></head><body class="framemenu"><xsl:call-template name="logoPicture"/><br/><xsl:text></xsl:text><xsl:call-template name="linkListContents"><xsl:with-param name="style" select="'toclist'"/></xsl:call-template><xsl:call-template name="stdfooterFrame"/><xsl:call-template name="bodyEndHook"/></body></html></xsl:template>