Commit a8059d83 authored by Dennis Neumann's avatar Dennis Neumann
Browse files

Add impoting of titles

parent 03ff7971
......@@ -10,23 +10,44 @@
<xsl:param name="currentArticleId" />
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="TEI">
<add>
<doc>
<field name="id">
<xsl:value-of select="$currentArticleId" />
</field>
<xsl:apply-templates select="teiHeader/fileDesc/titleStmt/title" mode="text_only" />
<field name="fulltext">
<xsl:apply-templates select="TEI/text/body/*" />
<xsl:apply-templates select="text/body/*" />
</field>
</doc>
</add>
</xsl:template>
<xsl:template match="title[@type='short']" mode="text_only">
<field name="short_title">
<xsl:apply-templates select="*|text()" mode="text_only" />
</field>
</xsl:template>
<xsl:template match="title[@type='desc']" mode="text_only">
<field name="title">
<xsl:apply-templates select="*|text()" mode="text_only" />
</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="p">
<xsl:apply-templates select="*|text()" />
</xsl:template>
<xsl:template match="text()">
<xsl:template match="text()" mode="#all">
<xsl:value-of select="." />
</xsl:template>
......
......@@ -36,21 +36,42 @@ public class XsltTest {
}
@Test
public void note_removeIfIsAComment() throws Exception {
public void fullTitleWithPlace_createsField() throws Exception {
String result = transform("title_full_with_place.xml");
assertXpathEvaluatesTo("My Berlin title", "//field[@name='title']", result);
}
@Test
public void fullTitle_createsField() throws Exception {
String result = transform("title_full.xml");
assertXpathEvaluatesTo("My full title", "//field[@name='title']", result);
}
@Test
public void shortTitle_createsField() throws Exception {
String result = transform("title_short.xml");
assertXpathEvaluatesTo("My short title", "//field[@name='short_title']", result);
}
@Test
public void note_removesIfIsAComment() throws Exception {
String result = transform("note-comment.xml");
assertXpathEvaluatesTo("before-note after-note", "//field[@name='fulltext']", result);
}
@Test
public void twoLinebreaks_replaceWithSpaces() throws Exception {
public void twoLinebreaks_replacesWithSpaces() throws Exception {
String result = transform("linebreaks-two.xml");
assertXpathEvaluatesTo("before middle after", "//field[@name='fulltext']", result);
}
@Test
public void linebreak_replaceWithSpace() throws Exception {
public void linebreak_replacesWithSpace() throws Exception {
String result = transform("linebreak.xml");
assertXpathEvaluatesTo("before after", "//field[@name='fulltext']", result);
......
<?xml version="1.0" encoding="UTF-8"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
<teiHeader>
<fileDesc>
<titleStmt>
<title type="desc">My full title</title>
</titleStmt>
</fileDesc>
</teiHeader>
<text xml:id="my_id" xml:lang="ger">
<body>
</body>
</text>
</TEI>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
<teiHeader>
<fileDesc>
<titleStmt>
<title type="desc">My <name type="place">Berlin</name> title</title>
</titleStmt>
</fileDesc>
</teiHeader>
<text xml:id="my_id" xml:lang="ger">
<body>
</body>
</text>
</TEI>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
<teiHeader>
<fileDesc>
<titleStmt>
<title type="short">My short title</title>
</titleStmt>
</fileDesc>
</teiHeader>
<text xml:id="my_id" xml:lang="ger">
<body>
</body>
</text>
</TEI>
\ No newline at end of file
......@@ -49,6 +49,8 @@
<field name="type" type="string" required="false" />
<field name="fulltext" type="text_de" multiValued="false" />
<field name="short_title" type="text_de" multiValued="false" />
<field name="title" type="text_de" multiValued="false" />
<!-- transaction log -->
<field name="_version_" type="long" indexed="true" stored="true" />
......
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