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/common.xsl
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
106 lines (98 sloc)
3.45 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:variable name="transl" select="document(eoa:conc_path($aux_uri, 'translations.xml'))"/> | |
<xsl:variable name="apos" as="xs:string">'</xsl:variable> | |
<xsl:function name="eoa:prepare_ref_strings" as="xs:string*"> | |
<xsl:param name="person_refs" as="xs:string*" /> | |
<xsl:variable name="person_refs_split" as="xs:string*" select="for $x in $person_refs return tokenize($x, '\s+')"/> | |
<xsl:sequence | |
select="for $x in $person_refs_split return substring-after($x, '#')" | |
/> | |
</xsl:function> | |
<xsl:template name="format_persons" as="xs:string"> | |
<xsl:param name="person_refs" as="xs:string*" /> | |
<!-- | |
<xsl:sequence select="eoa:debug(concat('person_refs: ', string-join($person_refs, ',')))"/> | |
--> | |
<xsl:variable name="ctxt" select="/"/> | |
<xsl:variable name="persons" as="element()*"> | |
<xsl:for-each select="eoa:prepare_ref_strings($person_refs)"> | |
<xsl:variable name="id" select="."/> | |
<!-- | |
<xsl:sequence select="eoa:debug(concat('id: ', string-join($id, ',')))"/> | |
--> | |
<xsl:variable name="person" as="element()?"> | |
<xsl:sequence select="$ctxt//*[@xml:id = $id]"/> | |
</xsl:variable> | |
<xsl:if test="not($person)"> | |
<xsl:sequence select="eoa:warning(concat('person with id ', $id, ' not found!'))"/> | |
</xsl:if> | |
<xsl:sequence select="$person"/> | |
</xsl:for-each> | |
</xsl:variable> | |
<xsl:variable name="num_persons" select="count($persons)"/> | |
<xsl:choose> | |
<xsl:when test="$num_persons >= 1"> | |
<xsl:value-of> | |
<xsl:for-each select="$persons"> | |
<xsl:variable name="formatted_author" select="concat(./tei:persName/tei:forename, ' ', ./tei:persName/tei:surname)"/> | |
<xsl:value-of select="$formatted_author"/> | |
<xsl:choose> | |
<xsl:when test="position() < $num_persons - 1"> | |
<xsl:text>, </xsl:text> | |
</xsl:when> | |
<xsl:when test="position()=$num_persons - 1"> | |
<xsl:text> and </xsl:text> | |
</xsl:when> | |
</xsl:choose> | |
</xsl:for-each> | |
</xsl:value-of> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="eoa:warning('no persons')"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:function name="eoa:conc_path" as="xs:string"> | |
<xsl:param name="p1" as="xs:string"/> | |
<xsl:param name="p2" as="xs:string"/> | |
<xsl:choose> | |
<xsl:when test="starts-with($p2, '/') or $p2 = '' or $p1 = ''"> | |
<xsl:sequence select="$p2"/> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:sequence select="concat(eoa:strip_pathsep($p1), '/', $p2)"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:function> | |
<xsl:function name="eoa:conc_path3" as="xs:string"> | |
<xsl:param name="p1" as="xs:string"/> | |
<xsl:param name="p2" as="xs:string"/> | |
<xsl:param name="p3" as="xs:string"/> | |
<xsl:sequence select="eoa:conc_path($p1, eoa:conc_path($p2, $p3))"/> | |
</xsl:function> | |
<xsl:function name="eoa:strip_pathsep" as="xs:string"> | |
<xsl:param name="path" as="xs:string"/> | |
<xsl:sequence select="replace($path, '/$', '')"/> | |
</xsl:function> | |
<xsl:template name="eoa:print_elem" as="xs:string"> | |
<xsl:value-of select=" | |
concat( | |
name(), | |
if( @type ) then concat('[@type = ', @type, ']') else '' | |
) | |
"/> | |
</xsl:template> | |
</xsl:stylesheet> |