Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
EOASkripts/src/stylesheets/tei2html/utils/html_inline.xsl
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
170 lines (151 sloc)
5.27 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<xsl:stylesheet | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:tei="http://www.tei-c.org/ns/1.0" | |
xmlns:xs="http://www.w3.org/2001/XMLSchema" | |
xmlns:eoa="http://www.edition-open-access.de/ns" | |
exclude-result-prefixes="xs tei eoa" | |
version="2.0" | |
> | |
<xsl:output | |
method="html" | |
encoding="UTF-8" | |
indent="yes" | |
/> | |
<xsl:key name="theoremdecls" match="tei:ab[@type = 'theoremdeclaration']" use="@xml:id"/> | |
<xsl:key name="theorems" match="tei:p[@corresp]" use="eoa:normalize_reference(@corresp)"/> | |
<!-- text inline elements: --> | |
<!-- mode="inline": convert inline elements to html --> | |
<!-- default rule: warning --> | |
<xsl:template mode="inline" match="tei:*" priority="-100"> | |
<xsl:variable name="elem"><xsl:call-template name="eoa:print_elem"/></xsl:variable> | |
<xsl:value-of select="eoa:warning(concat('in mode ', $apos, 'inline', $apos, ': no template for ', $elem))"/> | |
<!-- | |
<xsl:apply-templates/> | |
--> | |
</xsl:template> | |
<xsl:template mode="inline" match="tei:hi"> | |
<xsl:sequence select="eoa:info('markup')"/> | |
<xsl:choose> | |
<xsl:when test="@rend='italic'"> | |
<em> | |
<xsl:apply-templates/> | |
</em> | |
</xsl:when> | |
<xsl:when test="@rend='bold'"> | |
<b> | |
<xsl:apply-templates/> | |
</b> | |
</xsl:when> | |
<xsl:when test="@rend='superscript'"> | |
<sup> | |
<xsl:apply-templates/> | |
</sup> | |
</xsl:when> | |
<xsl:when test="@rend='subscript'"> | |
<sub> | |
<xsl:apply-templates/> | |
</sub> | |
</xsl:when> | |
<xsl:when test="@rend='smallcaps'"> | |
<sc> | |
<xsl:apply-templates/> | |
</sc> | |
</xsl:when> | |
<xsl:when test="@rend='math'"> | |
<i> | |
<xsl:apply-templates/> | |
</i> | |
</xsl:when> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template mode="inline" match="tei:lb"> | |
<br/> | |
</xsl:template> | |
<xsl:template mode="inline" match="tei:body//tei:foreign"> | |
<span lang="{@xml:lang}"> | |
<xsl:apply-templates/> | |
</span> | |
</xsl:template> | |
<xsl:template mode="inline" match="tei:formula[@rend='inline']"> | |
<xsl:sequence select="eoa:info('inline formula')"/> | |
<xsl:value-of select="concat('$', ., '$')"/> | |
</xsl:template> | |
<xsl:template mode="inline" match="tei:graphic"> | |
<xsl:sequence select="eoa:info('inline graphic')"/> | |
<xsl:variable name="full_url" select="eoa:conc_path3('../../..', $publ_static_url, @url)"/> | |
<img class="eoainlineimage" src="{$full_url}" alt="(missing pic)"/> | |
</xsl:template> | |
<xsl:template mode="inline" match="tei:note[@place = 'bottom']"> | |
<xsl:variable name="footnote_id" as="xs:string?"> | |
<xsl:call-template name="footnote_id"/> | |
</xsl:variable> | |
<a href="{concat('#', $footnote_id)}"> | |
<sup> | |
<xsl:value-of select="@n"/> | |
</sup> | |
</a> | |
</xsl:template> | |
<!-- | |
<xsl:template mode="inline" match="tei:bibl/tei:ref"> | |
<xsl:sequence select="eoa:warning('bibliographic reference dummy implementation')"/> | |
(reference to bibl.) | |
</xsl:template> | |
--> | |
<xsl:template mode="inline" match="tei:ref[@type = ('number', 'page')]"> | |
<xsl:variable name="target_id" select="eoa:normalize_reference(@target)"/> | |
<xsl:variable name="target" as="element()" select="//tei:*[@xml:id = $target_id]"/> | |
<xsl:apply-templates mode="render_ref" select="$target"> | |
<xsl:with-param name="ref_type" select="@type"/> | |
</xsl:apply-templates> | |
</xsl:template> | |
<xsl:template mode="inline" match="tei:ref[@type = 'url']"> | |
<a href="{@target}"> | |
<xsl:if test="tei:date/@when"> | |
<xsl:value-of select="concat('[', tei:date/@when, ']')"/> | |
</xsl:if> | |
<xsl:value-of select="@target"/> | |
</a> | |
</xsl:template> | |
<xsl:template mode="render_ref" match="*"> | |
<xsl:variable name="elem"><xsl:call-template name="eoa:print_elem"/></xsl:variable> | |
<xsl:sequence select="eoa:error('not implemented: reference to element ', $elem)"/> | |
</xsl:template> | |
<xsl:template mode="render_ref" match="tei:div[@type = ('chapter', 'section', 'subsection')]"> | |
<xsl:param name="ref_type" as="xs:string"/> | |
<xsl:variable name="uri"><xsl:call-template name="uri_from_chapter"/></xsl:variable> | |
<a href="{$uri}"> | |
<xsl:choose> | |
<xsl:when test="$ref_type = 'page'"> | |
<xsl:apply-templates mode="section_nr" select="."/> | |
<xsl:text> (pageref)</xsl:text> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:apply-templates mode="section_nr" select="."/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</a> | |
</xsl:template> | |
<xsl:template mode="render_ref" match="tei:figure"> | |
<xsl:variable name="uri"><xsl:call-template name="uri_from_chapter"/></xsl:variable> | |
<a href="{$uri}"> | |
<xsl:apply-templates mode="figure_nr" select="."/> | |
</a> | |
</xsl:template> | |
<xsl:template mode="render_ref" match="tei:table"> | |
<xsl:variable name="uri"><xsl:call-template name="uri_from_chapter"/></xsl:variable> | |
<a href="{$uri}"> | |
<xsl:apply-templates mode="table_nr" select="."/> | |
</a> | |
</xsl:template> | |
<!-- index elements should not be printed in the text. They are invisible markers from which to generate the index--> | |
<xsl:template mode="inline" match="tei:index"/> | |
<xsl:function name="eoa:normalize_reference"> | |
<xsl:param name="reference"/> | |
<xsl:analyze-string select="$reference" regex="#{{0,1}}(.+)"> | |
<xsl:matching-substring> | |
<xsl:value-of select="regex-group(1)"/> | |
</xsl:matching-substring> | |
</xsl:analyze-string> | |
</xsl:function> | |
</xsl:stylesheet> |