Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Formatting of multiple authors
  • Loading branch information
Klaus Thoden committed Aug 14, 2018
1 parent 03f2727 commit 43721bc
Showing 1 changed file with 35 additions and 7 deletions.
42 changes: 35 additions & 7 deletions data/tei2eoatex.xsl
Expand Up @@ -10,7 +10,6 @@
<xsl:strip-space elements="*"/>
<!--
make:
- formatting of several authors
- some fields could contain markup, this is currently ignored
-->

Expand Down Expand Up @@ -117,15 +116,44 @@
<xsl:text>}</xsl:text>
<xsl:text>{</xsl:text>
<xsl:apply-templates />
<!-- 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="not(../@resp)">
<xsl:message>INFO: No chapter author.</xsl:message>
<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:variable name="formatted_author" select="concat(./tei:persName/tei:forename, ' ', ./tei:persName/tei:surname)"/>
<xsl:value-of select="$formatted_author"/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<!-- needs formatting of several authors -->
<xsl:variable name="authorid" select="substring-after(../@resp, '#')"/>
<xsl:when test="$num_authors = 2">
<xsl:text>\EOAauthor{</xsl:text>
<xsl:value-of select="concat(//tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:respStmt[@xml:id=$authorid]/tei:persName/tei:forename, ' ', //tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:respStmt[@xml:id=$authorid]/tei:persName/tei:surname)"/>
<xsl:for-each select="//tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:respStmt[contains($authors, @xml:id)]">
<xsl:variable name="formatted_author" select="concat(./tei:persName/tei:forename, ' ', ./tei:persName/tei:surname)"/>
<xsl:value-of select="$formatted_author"/>
<xsl:if test="position()!=last()">
<xsl:text> and </xsl:text>
</xsl:if>
</xsl:for-each>
</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: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() &lt; $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:when>
<xsl:otherwise>
<xsl:message>INFO: No chapter author.</xsl:message>
<xsl:text>}</xsl:text>
</xsl:otherwise>
</xsl:choose>
Expand Down

0 comments on commit 43721bc

Please sign in to comment.