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/tei2eoatex/eoatex_persons.xsl
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
157 lines (153 sloc)
6.65 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:xlink="http://www.w3.org/1999/xlink" | |
xmlns:eoa="http://www.edition-open-access.de/ns" | |
exclude-result-prefixes="xs tei" | |
version="2.0"> | |
<xsl:template name="combine_names"> | |
<xsl:choose> | |
<xsl:when test="./tei:persName/@xml:lang='zh'"> | |
<xsl:variable name="formatted_author" select="concat(./tei:persName/tei:surname, ' ', ./tei:persName/tei:forename)"/> | |
<xsl:value-of select="$formatted_author"/> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:variable name="formatted_author" select="concat(./tei:persName/tei:forename, ' ', ./tei:persName/tei:surname)"/> | |
<xsl:value-of select="$formatted_author"/> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="format_persons"> | |
<xsl:param name="people"/> | |
<xsl:variable name="joined_people" select="string-join($people, '')"/> | |
<xsl:variable name="num_people" select="count($people)"/> | |
<xsl:choose> | |
<xsl:when test="$num_people = 1"> | |
<xsl:for-each select="//tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:respStmt[contains($joined_people, @xml:id)]"> | |
<xsl:call-template name="combine_names"/> | |
</xsl:for-each> | |
</xsl:when> | |
<xsl:when test="$num_people = 2"> | |
<xsl:for-each select="//tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:respStmt[contains($joined_people, @xml:id)]"> | |
<xsl:call-template name="combine_names"/> | |
<xsl:if test="position()!=last()"> | |
<xsl:text> and </xsl:text> | |
</xsl:if> | |
</xsl:for-each> | |
</xsl:when> | |
<xsl:when test="$num_people > 2"> | |
<xsl:for-each select="//tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:respStmt[contains($joined_people, @xml:id)]"> | |
<xsl:call-template name="combine_names"/> | |
<!-- <xsl:value-of select="concat(./tei:persName/tei:forename, ' ', ./tei:persName/tei:surname)"/> --> | |
<xsl:choose> | |
<xsl:when test="position() < $num_people - 1"> | |
<xsl:text>, </xsl:text> | |
</xsl:when> | |
<xsl:when test="position()=$num_people - 1"> | |
<xsl:text>, and </xsl:text> | |
</xsl:when> | |
</xsl:choose> | |
</xsl:for-each> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="eoa:debug(3, 'No book author. Exiting.', '')" /> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<xsl:template name="chapterauthor"> | |
<!-- next with thanks to https://www.oxygenxml.com/forum/topic712.html --> | |
<xsl:variable name="authors" select="../@resp"/> | |
<xsl:variable name="num_authors" select="count(//tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:respStmt[contains($authors, @xml:id)])"/> | |
<xsl:choose> | |
<xsl:when test="$num_authors = 1"> | |
<xsl:text>\EOAchapterauthor{</xsl:text> | |
<xsl:for-each select="//tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:respStmt[contains($authors, @xml:id)]"> | |
<xsl:call-template name="combine_names"/> | |
</xsl:for-each> | |
<xsl:text>}</xsl:text> | |
</xsl:when> | |
<xsl:when test="$num_authors = 2"> | |
<xsl:text>\EOAchapterauthor{</xsl:text> | |
<xsl:for-each select="//tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:respStmt[contains($authors, @xml:id)]"> | |
<xsl:call-template name="combine_names"/> | |
<xsl:if test="position()!=last()"> | |
<xsl:text> and </xsl:text> | |
</xsl:if> | |
</xsl:for-each> | |
<xsl:text>}</xsl:text> | |
</xsl:when> | |
<xsl:when test="$num_authors > 2"> | |
<xsl:text>\EOAchapterauthor{</xsl:text> | |
<xsl:for-each select="//tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:respStmt[contains($authors, @xml:id)]"> | |
<xsl:call-template name="combine_names"/> | |
<xsl:choose> | |
<xsl:when test="position() < $num_authors - 1"> | |
<xsl:text>, </xsl:text> | |
</xsl:when> | |
<xsl:when test="position()=$num_authors - 1"> | |
<xsl:text>, and </xsl:text> | |
</xsl:when> | |
</xsl:choose> | |
</xsl:for-each> | |
<xsl:text>}</xsl:text> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="eoa:debug(1, 'No chapter author: ', node())" /> | |
</xsl:otherwise> | |
</xsl:choose> | |
<xsl:choose> | |
<xsl:when test="following-sibling::*[1][self::tei:ab[@type='authorbio']]"> | |
<xsl:text>{</xsl:text> | |
<xsl:apply-templates select="following-sibling::*[1][self::tei:ab[@type='authorbio']]"/> | |
<xsl:text>}</xsl:text> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:text>{none}</xsl:text> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
<!-- next with thanks to https://www.oxygenxml.com/forum/topic712.html --> | |
<!-- expected ctxt: div[@type = 'chapter'] --> | |
<xsl:template name="eoaauthor"> | |
<xsl:variable name="authors" select="@resp"/> | |
<xsl:variable name="num_authors" select="count(//tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:respStmt[contains($authors, @xml:id)])"/> | |
<xsl:choose> | |
<xsl:when test="$num_authors = 1"> | |
<xsl:text>\EOAauthor{</xsl:text> | |
<xsl:for-each select="//tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:respStmt[contains($authors, @xml:id)]"> | |
<xsl:call-template name="combine_names"/> | |
</xsl:for-each> | |
<xsl:text>}</xsl:text> | |
</xsl:when> | |
<xsl:when test="$num_authors = 2"> | |
<xsl:text>\EOAauthor{</xsl:text> | |
<xsl:for-each select="//tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:respStmt[contains($authors, @xml:id)]"> | |
<xsl:call-template name="combine_names"/> | |
<xsl:if test="position()!=last()"> | |
<xsl:text> and </xsl:text> | |
</xsl:if> | |
</xsl:for-each> | |
<xsl:text>}</xsl:text> | |
</xsl:when> | |
<xsl:when test="$num_authors > 2"> | |
<xsl:text>\EOAauthor{</xsl:text> | |
<xsl:for-each select="//tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:respStmt[contains($authors, @xml:id)]"> | |
<xsl:call-template name="combine_names"/> | |
<xsl:choose> | |
<xsl:when test="position() < $num_authors - 1"> | |
<xsl:text>, </xsl:text> | |
</xsl:when> | |
<xsl:when test="position()=$num_authors - 1"> | |
<xsl:text>, and </xsl:text> | |
</xsl:when> | |
</xsl:choose> | |
</xsl:for-each> | |
<xsl:text>}</xsl:text> | |
</xsl:when> | |
<xsl:otherwise> | |
<xsl:value-of select="eoa:debug(1, 'No chapter author: ', '')" /> | |
</xsl:otherwise> | |
</xsl:choose> | |
</xsl:template> | |
</xsl:stylesheet> |