de-francophones's picture
Upload 173 files
9a1f9ba verified
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:eg="http://www.tei-c.org/ns/Examples"
xmlns:tei="http://www.tei-c.org/ns/1.0"
xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
xmlns:exsl="http://exslt.org/common"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
extension-element-prefixes="exsl msxsl"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:html="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="xsl tei xd eg fn #default">
<!-- import teibp.xsl, which allows templates,
variables, and parameters from teibp.xsl
to be overridden here. -->
<xsl:import href="https://repository.ortolang.fr/api/content/tei-boilerplate-custom/latest/content/teibp.xsl"/>
<!-- <xsl:template match="tei:pb"> -->
<!-- we have to solve the pointer ; either it already is an http link,
or it is an xml pointer towards the facsilime part of the tei file -->
<!-- well, in practice, we know it is a pointer towards the facsimile ! -->
<!-- moreover, we should have all images not refered to by a pb diosplayed first... -->
<!-- </xsl:template> -->
<xsl:template match="tei:pb[@facs]">
<xsl:param name="pn">
<xsl:number count="//tei:pb" level="any"/>
</xsl:param>
<xsl:variable name="theFacs" select="@facs"/>
<xsl:variable name="theImage" select="//tei:surface[concat('#', @xml:id) = $theFacs]/tei:graphic/@url"/>
<xsl:choose>
<xsl:when test="$displayPageBreaks = true()">
<span class="-teibp-pb">
<xsl:call-template name="addID"/>
<xsl:call-template name="pb-handler">
<xsl:with-param name="n" select="@n"/>
<xsl:with-param name="facs" select="$theImage"/>
<xsl:with-param name="id">
<xsl:choose>
<xsl:when test="@xml:id">
<xsl:value-of select="@xml:id"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="generate-id()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
</xsl:call-template>
</span>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="tei:facsimile">
<xsl:text>Pièces annexes (sceaux, verso, etc...)</xsl:text>
<xsl:apply-templates/>
<br/>
</xsl:template>
<!-- <xsl:template match="tei:text">
<xsl:text>Le texte :</xsl:text>
<xsl:apply-templates/>
</xsl:template> -->
<xsl:template match="tei:surface">
<xsl:variable name="myId" select="@xml:id"/>
<xsl:variable name="theImage" select="tei:graphic/@url"/>
<xsl:if test="not(//tei:pb[@facs=concat('#', $myId)])">
<span class="-teibp-pb">
<xsl:call-template name="addID"/>
<xsl:call-template name="pb-handler">
<xsl:with-param name="n" select="0"/>
<xsl:with-param name="facs" select="$theImage"/>
<xsl:with-param name="id">
<xsl:choose>
<xsl:when test="@xml:id">
<xsl:value-of select="@xml:id"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="generate-id()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
</xsl:call-template>
</span>
</xsl:if>
</xsl:template>
<!--<xsl:template match="tei:item">
<span id="translate(tei:persname/text(), ' ', '_')">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy></span>
</xsl:template> -->
<xsl:template match="tei:table">
<table>
<xsl:apply-templates/>
</table>
</xsl:template>
<xsl:template match="tei:row">
<tr>
<xsl:apply-templates select="tei:cell[1]"/>
<xsl:text> </xsl:text>
<em><xsl:apply-templates select="tei:cell[2]"/></em>
<xsl:text> </xsl:text>
<xsl:apply-templates select="tei:cell[3]"/>
</tr>
</xsl:template>
<xsl:template match="tei:cell">
<td>
<xsl:variable name="contexte">25</xsl:variable>
<xsl:choose>
<xsl:when test="preceding-sibling::tei:cell and following-sibling::tei:cell">
<xsl:attribute name="style">text-align:center;</xsl:attribute>
<xsl:apply-templates/>
</xsl:when>
<xsl:when test="not(following-sibling::tei:cell)">
<xsl:value-of select="substring(., 1, $contexte)"/>
</xsl:when>
<xsl:when test="not(preceding-sibling::tei:cell)">
<xsl:variable name="bi">
<xsl:value-of select="string-length(.)-$contexte"/>
</xsl:variable>
<xsl:variable name="max">
<xsl:choose>
<xsl:when test="$bi &lt; 1">
<xsl:text>1</xsl:text>
</xsl:when>
<xsl:otherwise><xsl:value-of select="$bi"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="substring(., $max, string-length(.))"/>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="style">text-align:center;</xsl:attribute>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</td>
</xsl:template>
<xsl:template match="tei:persName">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="tei:ref">
<a href="{@target}"><xsl:apply-templates/></a>
</xsl:template>
</xsl:stylesheet>