Commit 602fa41c authored by Dennis Neumann's avatar Dennis Neumann
Browse files

Refactor XSLT

parent e864051c
......@@ -8,78 +8,88 @@
<xsl:strip-space elements="*" />
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="TEI">
<add>
<doc>
<field name="id">
<xsl:value-of select="text/@xml:id" />
</field>
<xsl:apply-templates select="teiHeader/fileDesc/titleStmt/title" mode="text_only" />
<xsl:apply-templates select="teiHeader/fileDesc/titleStmt/title[@type='desc']/name" mode="make_field" />
<xsl:apply-templates select="teiHeader/fileDesc/titleStmt/title[@type='desc']/date[@type='orn']" mode="make_field" />
<xsl:apply-templates select="teiHeader/fileDesc/titleStmt/author/name" mode="text_only" />
<field name="fulltext">
<xsl:apply-templates select="text/body/*" mode="text_only" />
</field>
<xsl:apply-templates select="TEI" />
</doc>
</add>
</xsl:template>
<xsl:template match="title[@type='short']" mode="text_only">
<xsl:template match="TEI">
<xsl:apply-templates select="teiHeader | text" />
</xsl:template>
<xsl:template match="text()" mode="#all">
<xsl:value-of select="replace(., '\s+', ' ')" />
</xsl:template>
<!--########### Header #######################-->
<xsl:template match="teiHeader">
<xsl:apply-templates select="fileDesc" />
</xsl:template>
<xsl:template match="fileDesc">
<xsl:apply-templates select="titleStmt/title" />
<xsl:apply-templates select="titleStmt/title[@type='desc']/name" />
<xsl:apply-templates select="titleStmt/title[@type='desc']/date[@type='orn']" />
<xsl:apply-templates select="titleStmt/author/name" />
</xsl:template>
<xsl:template match="title[@type='short']">
<field name="short_title">
<xsl:apply-templates select="*|text()" mode="text_only" />
<xsl:apply-templates mode="text_only" />
</field>
</xsl:template>
<xsl:template match="title[@type='desc']" mode="text_only">
<xsl:template match="title[@type='desc']">
<field name="title">
<xsl:apply-templates select="*|text()" mode="text_only" />
<xsl:apply-templates mode="text_only" />
</field>
</xsl:template>
<xsl:template match="name[@type='place' and @subtype='orn']" mode="make_field">
<xsl:template match="title/name[@type='place' and @subtype='orn']">
<field name="origin_place">
<xsl:apply-templates select="*|text()" mode="text_only" />
</field>
</xsl:template>
<xsl:template match="name[@type='place' and @subtype='dtn']" mode="make_field">
<xsl:template match="title/name[@type='place' and @subtype='dtn']">
<field name="destination_place">
<xsl:apply-templates select="*|text()" mode="text_only" />
<xsl:apply-templates mode="text_only" />
</field>
</xsl:template>
<xsl:template match="name[@type='person' and @subtype='rcp']" mode="make_field">
<xsl:template match="title/name[@type='person' and @subtype='rcp']">
<field name="recipient">
<xsl:apply-templates select="*|text()" mode="text_only" />
<xsl:apply-templates mode="text_only" />
</field>
</xsl:template>
<xsl:template match="date[@type='orn']" mode="make_field">
<xsl:template match="title/date[@type='orn']">
<field name="origin_date">
<xsl:value-of select="@when" />
</field>
</xsl:template>
<xsl:template match="name[@type='place']" mode="text_only">
<xsl:apply-templates select="*|text()" mode="text_only" />
</xsl:template>
<xsl:template match="name[@type='person' and @subtype='aut']" mode="text_only">
<xsl:template match="author/name[@type='person' and @subtype='aut']">
<field name="author">
<xsl:apply-templates select="*|text()" mode="text_only" />
<xsl:apply-templates mode="text_only" />
</field>
</xsl:template>
<xsl:template match="p" mode="text_only">
<xsl:apply-templates select="*|text()" mode="text_only" />
</xsl:template>
<xsl:template match="text()" mode="#all">
<xsl:value-of select="replace(., '\s+', ' ')" />
<!--################### text/body ##########################-->
<xsl:template match="text">
<field name="id">
<xsl:value-of select="@xml:id" />
</field>
<field name="fulltext">
<xsl:apply-templates select="body/*" mode="text_only" />
</field>
</xsl:template>
<xsl:template match="lb" mode="text_only">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment