Skip to content
Permalink
bb62c8f227
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
377 lines (359 sloc) 16.8 KB
<?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:param name="frontmatter" as="xs:boolean" required="no" select="false()"/>
<xsl:param name="contributors" as="xs:boolean" required="no" select="false()"/>
<xsl:param name="strictfloats" as="xs:boolean" required="no" select="false()"/>
<xsl:param name="indentfloats" as="xs:boolean" required="no" select="false()"/>
<xsl:param name="manualpreambel" as="xs:boolean" required="no" select="false()"/>
<xsl:param name="hyphenation" as="xs:boolean" required="no" select="false()"/>
<xsl:param name="verbosity" as="xs:integer" required="no" select="0"/>
<xsl:include href="tei2eoatex/eoatex_contributors.xsl"/>
<xsl:include href="tei2eoatex/eoatex_frontmatter.xsl"/>
<xsl:include href="tei2eoatex/eoatex_functions.xsl"/>
<xsl:include href="tei2eoatex/eoatex_persons.xsl"/>
<xsl:include href="tei2eoatex/eoatex_processinginstructions.xsl"/>
<xsl:include href="tei2eoatex/eoatex_textparts.xsl"/>
<xsl:variable name="langid" select="//tei:langUsage/tei:language/@ident"/>
<xsl:variable name="transl" select="document('data/aux/translations.xml')"/>
<xsl:key name="en" match="translations/entry" use="@en"/>
<xsl:key name="de" match="translations/entry" use="@de"/>
<xsl:key name="fr" match="translations/entry" use="@fr"/>
<xsl:key name="it" match="translations/entry" use="@it"/>
<xsl:output method="text" encoding="UTF-8" use-character-maps="texreplacements"/>
<xsl:character-map name="texreplacements">
<!--
the character map replaces characters
In the stylesheet below, a sign (&#x2E0E;) is used to denote a
comment in LaTeX. The sign itself is unlikely to occur in the
text. The LaTeX comment sign is originally a percent sign, but
since this the percent sign needs to be escaped in other
contexts, a double replacement is performed.
-->
<xsl:output-character character="&#x23;" string="\#"/>
<xsl:output-character character="&#x26;" string="\&amp;"/>
<xsl:output-character character="&#x25;" string="\%"/>
<xsl:output-character character="&#x2E0E;" string="%"/>
<xsl:output-character character="&#x00A0;" string="~"/>
<xsl:output-character character="&#x2E0F;" string="&amp;"/>
</xsl:character-map>
<xsl:template match="*">
<!--
catchall template
https://stackoverflow.com/questions/3360017/why-does-xslt-output-all-text-by-default
-->
<xsl:value-of select="eoa:debug(2, 'Unmatched element: ', name())"/>
<xsl:apply-templates/>
</xsl:template>
<!-- ignore some header fields -->
<xsl:template match="//tei:teiHeader/tei:fileDesc/tei:titleStmt/tei:author|tei:editor|tei:resp|tei:persName"/>
<xsl:template match="//tei:teiHeader/tei:fileDesc/tei:editionStmt|tei:publicationStmt"/>
<xsl:template match="//tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:p"/>
<xsl:template match="//tei:teiHeader/tei:encodingDesc|tei:profileDesc|tei:revisionDesc"/>
<xsl:template match="/">
<xsl:value-of select="eoa:texcomment(concat('LaTeX output, generated by script tei2eoatex.xsl on ', current-dateTime()))" />
<xsl:value-of select="eoa:texcomment(concat('Using ', system-property('xsl:product-name'), system-property('xsl:product-version'), ' by ', system-property('xsl:vendor'), ' (', system-property('xsl:vendor-url'), ')'))" />
<xsl:text>&#x000a;</xsl:text>
<xsl:choose>
<xsl:when test="$manualpreambel">
<xsl:text>\input{preambel/pre_eoa}&#x000a;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="eoa:texcomment('Preambel is to be attached by eoatex2pdf script')"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>\EOAbibliographytype{</xsl:text>
<xsl:value-of select="//tei:sourceDesc/tei:ab[@type='bibdatabase']/tei:ref/@type"/>
<xsl:text>}&#x000a;</xsl:text>
<xsl:text>\EOAbibliographydatabase{</xsl:text>
<xsl:value-of select="substring-before(//tei:sourceDesc/tei:ab[@type='bibdatabase']/tei:ref/@target, '.bib')"/>
<xsl:text>}&#x000a;</xsl:text>
<xsl:text>\EOAseries{</xsl:text>
<xsl:apply-templates select="//tei:seriesStmt/tei:title"/>
<xsl:text>}&#x000a;</xsl:text>
<xsl:choose>
<xsl:when test="$hyphenation">
<xsl:text>\input{texfiles/hyphenation}&#x000a;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="eoa:texcomment('No hyphenation rules added.')"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>&#x000a;\begin{document}&#x000a;</xsl:text>
<xsl:choose>
<xsl:when test="$frontmatter">
<xsl:text>\input{texfiles/frontmatter.tex}&#x000a;</xsl:text>
<xsl:call-template name="writefrontmatter"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="eoa:debug(1, 'Not writing the frontmatter.', '')" />
<xsl:text>&#x000a;</xsl:text>
<xsl:value-of select="eoa:texcomment('No frontmatter created yet. Insert it like so:')" />
<xsl:value-of select="eoa:texcomment('\input{texfiles/frontmatter.tex}')" />
<xsl:text>&#x000a;</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text>\pagenumbering{arabic}&#x000a;\setcounter{page}{1}&#x000a;\EOAtoc&#x000a; <!--\EOAnewpage&#x000a;-->
</xsl:text>
<xsl:choose>
<xsl:when test="$contributors">
<xsl:text>&#x000a;\EOAchapternonumber{List of Contributors}{List of Contributors}&#x000a;</xsl:text>
<xsl:text>\input{texfiles/contributors.tex}&#x000a;&#x000a;</xsl:text>
<xsl:call-template name="writecontributors"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="eoa:debug(1, 'Not writing list of contributors.', node())" />
<xsl:text>&#x000a;</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="//tei:body//tei:div[@type='part']">
<xsl:value-of select="eoa:debug(1, 'Book has parts. ', name())"/>
<xsl:call-template name="hasparts"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="eoa:debug(1, 'Book has no parts, the highest level is chapter. ', name())"/>
<xsl:call-template name="hasnoparts"/>
</xsl:otherwise>
</xsl:choose>
<xsl:text>\end{document}&#x000a;</xsl:text>
</xsl:template>
<!-- <xsl:template match="/"> ends here -->
<xsl:template name="hasparts">
<xsl:for-each select="//tei:body/tei:div[@type='chapter']/tei:head">
<xsl:result-document method="text" include-content-type="no" href="{concat('texfiles/beforepart-chapter', format-number(position(), '00'), '.tex')}">
<xsl:value-of select="eoa:texcomment('A subordinate file.')" />
<xsl:choose>
<xsl:when test="following-sibling::*[1][self::tei:ab[@type='authorbio']]">
<xsl:apply-templates select="../*[position() > 2]"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="../*[position() > 1]"/>
</xsl:otherwise>
</xsl:choose>
</xsl:result-document>
<xsl:text>\EOAchapter</xsl:text>
<xsl:choose>
<xsl:when test="../@n='nonumber'">
<xsl:text>nonumber</xsl:text>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="./tei:choice">
<xsl:text>{</xsl:text>
<xsl:apply-templates select="./tei:choice/tei:abbr"/>
<xsl:text>}{</xsl:text>
<xsl:apply-templates select="./tei:choice/tei:expan"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>{</xsl:text>
<xsl:apply-templates select="."/>
<xsl:text>}{</xsl:text>
<xsl:apply-templates select="."/>
</xsl:otherwise>
</xsl:choose>
<!-- <xsl:text>{</xsl:text>
<xsl:apply-templates select="."/>-->
<xsl:choose>
<xsl:when test="not(../@xml:id)">
<xsl:text>}&#x000a;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>}\EOAlabel{</xsl:text>
<xsl:value-of select="../@xml:id"/>
<xsl:text>}&#x000a;</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text>\input{</xsl:text>
<xsl:value-of select="concat('texfiles/beforepart-chapter', format-number(position(), '00'), '.tex')"/>
<xsl:text>}&#x000a;&#x000a;</xsl:text>
</xsl:for-each>
<xsl:for-each select="//tei:div[@type='part']/tei:head">
<xsl:variable name="partposition" select="position()"/>
<xsl:text>\EOApart{</xsl:text>
<xsl:apply-templates select="."/>
<xsl:choose>
<xsl:when test="not(../@xml:id)">
<xsl:value-of select="eoa:debug(1, 'No ID for part', node())" />
<xsl:text>}&#x000a;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>}\EOAlabel{</xsl:text>
<xsl:value-of select="../@xml:id"/>
<xsl:text>}&#x000a;</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:for-each select="../tei:div[@type='chapter' or @type='chapteroriginal' or @type='chaptertranslation' or @type='indexchapter']/tei:head">
<xsl:choose>
<xsl:when test="../@type='indexchapter'">
<xsl:text>\EOAtocentry{</xsl:text>
<xsl:apply-templates select="."/>
<xsl:text>}</xsl:text>
<xsl:apply-templates select="../tei:p"/>
<xsl:text>&#x000a;&#x000a;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>\EOAchapter</xsl:text>
<xsl:choose>
<xsl:when test="../@n='nonumber'">
<xsl:text>nonumber</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="eoa:debug(1, 'Section has number: ', node())" />
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="./tei:choice">
<xsl:text>{</xsl:text>
<xsl:apply-templates select="./tei:choice/tei:abbr"/>
<xsl:text>}{</xsl:text>
<xsl:apply-templates select="./tei:choice/tei:expan"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>{</xsl:text>
<xsl:apply-templates select="."/>
<xsl:text>}{</xsl:text>
<xsl:apply-templates select="."/>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="eoaauthor"/>
<xsl:text>}</xsl:text>
<xsl:text>&#x000a;</xsl:text>
<xsl:choose>
<xsl:when test="not(../@xml:id)">
<xsl:value-of select="eoa:debug(1, 'Chapter has no ID: ', node())" />
</xsl:when>
<xsl:otherwise>
<xsl:text>\EOAlabel{</xsl:text>
<xsl:value-of select="../@xml:id"/>
<xsl:text>}&#x000a;</xsl:text>
</xsl:otherwise>
</xsl:choose>
<!-- <xsl:call-template name="chapterauthor"/> -->
<xsl:text>&#x000a;\input{</xsl:text>
<xsl:value-of select="concat('texfiles/part', $partposition, '-chapter', format-number(position(), '00'), '.tex')"/>
<xsl:text>}&#x000a;&#x000a;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:for-each select="../tei:div[@type='chapter' or @type='chapteroriginal' or @type='chaptertranslation']">
<!-- <xsl:variable name="chapterposition" select="position()"/> -->
<xsl:result-document method="text" include-content-type="no" href="{concat('texfiles/part', $partposition, '-chapter', format-number(position(), '00'), '.tex')}">
<xsl:value-of select="eoa:texcomment('A subordinate file.')" />
<xsl:choose>
<xsl:when test="../tei:div[@type='chapteroriginal']">
<xsl:text>\vspace{-2\baselineskip}</xsl:text>
<xsl:text>\noindent\EOAemph{Traduzione italiana a p.~\EOApageref{</xsl:text>
<xsl:value-of select="substring-after(@corresp, '#')"/>
<xsl:text>}.}</xsl:text>
<xsl:text>\vspace{2\baselineskip}</xsl:text>
</xsl:when>
<xsl:when test="../tei:div[@type='chaptertranslation']">
<xsl:text>\vspace{-2\baselineskip}</xsl:text>
<xsl:text>\noindent\EOAemph{Versione originale latina a p.~\EOApageref{</xsl:text>
<xsl:value-of select="substring-after(@corresp, '#')"/>
<xsl:text>}.}</xsl:text>
<xsl:text>\vspace{2\baselineskip}</xsl:text>
</xsl:when>
</xsl:choose>
<xsl:choose>
<!--
<xsl:when test="following-sibling::*[1][self::tei:ab[@type='authorbio']] and following-sibling::*[2][self::tei:ab[@type='chapterabstract']]">
<xsl:apply-templates select="*[position() > 2]"/>
</xsl:when>
-->
<xsl:when test="following-sibling::*[1][self::tei:ab[@type='chapterabstract']]">
<xsl:apply-templates select="*[position() > 2]"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="*[position() > 1]"/>
</xsl:otherwise>
</xsl:choose>
</xsl:result-document>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
<!-- <xsl:template name="hasparts"> ends here -->
<xsl:template name="hasnoparts">
<xsl:for-each select="//tei:body/tei:div[@type='chapter' or @type='chapteroriginal' or @type='chaptertranslation' or @type='indexchapter']/tei:head">
<xsl:choose>
<xsl:when test="../@type='indexchapter'">
<xsl:text>\EOAtocentry{</xsl:text>
<xsl:apply-templates select="."/>
<xsl:text>}</xsl:text>
<xsl:apply-templates select="../tei:p"/>
<xsl:text>&#x000a;&#x000a;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>\EOAchapter</xsl:text>
<xsl:choose>
<xsl:when test="../@n='nonumber'">
<xsl:text>nonumber</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="eoa:debug(1, 'Section has number: ', node())" />
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="./tei:choice">
<xsl:text>{</xsl:text>
<xsl:apply-templates select="./tei:choice/tei:abbr"/>
<xsl:text>}{</xsl:text>
<xsl:apply-templates select="./tei:choice/tei:expan"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>{</xsl:text>
<xsl:apply-templates select="."/>
<xsl:text>}{</xsl:text>
<xsl:apply-templates select="."/>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="eoaauthor"/>
<xsl:text>}&#x000a;</xsl:text>
<xsl:choose>
<xsl:when test="not(../@xml:id)">
<xsl:value-of select="eoa:debug(1, 'Chapter has no ID: ', node())" />
</xsl:when>
<xsl:otherwise>
<xsl:text>\EOAlabel{</xsl:text>
<xsl:value-of select="../@xml:id"/>
<xsl:text>}&#x000a;</xsl:text>
</xsl:otherwise>
</xsl:choose>
<!-- <xsl:call-template name="chapterauthor"/> -->
<xsl:text>&#x000a;\input{</xsl:text>
<xsl:value-of select="concat('texfiles/chapter', format-number(position(), '00'), '.tex')"/>
<xsl:text>}&#x000a;&#x000a;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:for-each select="//tei:div[@type='chapter']">
<xsl:result-document method="text" include-content-type="no" href="{concat('texfiles/chapter', format-number(position(), '00'), '.tex')}">
<xsl:choose>
<xsl:when test="child::*[2][self::tei:ab[@type='authorbio']] and child::*[3][self::tei:ab[@type='chapterabstract']]">
<xsl:apply-templates select="*[position() > 2]"/>
</xsl:when>
<xsl:when test="child::*[2][self::tei:ab[@type='authorbio']]">
<xsl:apply-templates select="*[position() > 2]"/>
</xsl:when>
<xsl:when test="child::*[2][self::tei:ab[@type='chapterabstract']]">
<xsl:apply-templates select="*[position() > 2]"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="*[position() > 1]"/>
</xsl:otherwise>
</xsl:choose>
</xsl:result-document>
</xsl:for-each>
</xsl:template>
<!-- <xsl:template name="hasnoparts"> ends here -->
<!-- https://stackoverflow.com/questions/5035501/how-do-i-replace-sequences-of-whitespaces-by-one-space-but-dont-trim-in-xslt -->
<xsl:template match="text()">
<xsl:value-of select="translate(normalize-space(concat('&#x7F;',.,'&#x7F;')),'&#x7F;','')"/>
</xsl:template>
</xsl:stylesheet>