Commit 578904f9 authored by Dennis Neumann's avatar Dennis Neumann
Browse files

Add more transformations TEI -> HTML

parent 2f6b9d95
......@@ -6,7 +6,7 @@
<xsl:output method="xml" indent="yes" saxon:suppress-indentation="div" />
<xsl:strip-space elements="*" />
<xsl:preserve-space elements="msIdentifier bibl" />
<xsl:preserve-space elements="msIdentifier bibl p" />
<xsl:template match="/">
<add>
......@@ -135,6 +135,14 @@
<xsl:text> </xsl:text>
</xsl:template>
<xsl:template match="pb" mode="text_only">
<xsl:text> </xsl:text>
</xsl:template>
<xsl:template match="space" mode="text_only">
<xsl:text> </xsl:text>
</xsl:template>
<xsl:template match="note[@type='com']" mode="text_only">
</xsl:template>
......@@ -195,11 +203,65 @@
</div>
</xsl:template>
<xsl:template match="name[@type='object']" mode="html_for_whole_article">
<div class="object">
<xsl:apply-templates mode="html_for_whole_article" />
</div>
</xsl:template>
<xsl:template match="pb" mode="html_for_whole_article">
<div class="page-break">
<xsl:text>---(neue Seite)---</xsl:text>
</div>
</xsl:template>
<xsl:template match="seg" mode="html_for_whole_article">
<div class="seg">
<xsl:apply-templates mode="html_for_whole_article" />
</div>
</xsl:template>
<xsl:template match="rs[@type='person']" mode="html_for_whole_article">
<div class="rs-person">
<xsl:apply-templates mode="html_for_whole_article" />
</div>
</xsl:template>
<xsl:template match="note[@type='com']" mode="html_for_whole_article">
<div class="note-comment">
<xsl:apply-templates mode="html_for_whole_article" />
</div>
</xsl:template>
<xsl:template match="hi[@rendition='simple:underline']" mode="html_for_whole_article">
<div class="underline">
<xsl:apply-templates mode="html_for_whole_article" />
</div>
</xsl:template>
<xsl:template match="hi[@rendition='simple:superscript']" mode="html_for_whole_article">
<div class="superscript">
<xsl:apply-templates mode="html_for_whole_article" />
</div>
</xsl:template>
<xsl:template match="hi[@rendition='simple:italic']" mode="html_for_whole_article">
<div class="italic">
<xsl:apply-templates mode="html_for_whole_article" />
</div>
</xsl:template>
<xsl:template match="bibl" mode="html_for_whole_article">
<div class="bibl">
<xsl:apply-templates mode="html_for_whole_article" />
</div>
</xsl:template>
<xsl:template match="ref[@target]" mode="html_for_whole_article">
<a href="{@target}">
<xsl:apply-templates mode="html_for_whole_article" />
</a>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
......@@ -36,6 +36,44 @@ public class XsltHtmlTest {
System.out.println(outputBaos.toString());
}
@Test
public void object() throws Exception {
String html = transform("object.xml");
assertXpathEvaluatesTo("my object", "//div[@class='object']", html);
}
@Test
public void biblRef_makesAhref() throws Exception {
String html = transform("bibl-ref.xml");
assertXpathEvaluatesTo("my link", "//a", html);
}
@Test
public void hiRenditions() throws Exception {
String html = transform("hi-renditions.xml");
assertXpathEvaluatesTo("underlined", "//div[@class='underline']", html);
assertXpathEvaluatesTo("superscripted", "//div[@class='superscript']", html);
assertXpathEvaluatesTo("italicized", "//div[@class='italic']", html);
}
@Test
public void noteComment() throws Exception {
String html = transform("note-comment.xml");
assertXpathEvaluatesTo("A note.", "//div[@class='note-comment']", html);
}
@Test
public void segWithRs() throws Exception {
String html = transform("seg-with-rs-person.xml");
assertXpathEvaluatesTo("hiesigen Mechanikers", "//div[@class='seg']", html);
assertXpathEvaluatesTo("Mechanikers", "//div[@class='rs-person']", html);
}
@Test
public void person() throws Exception {
String html = transform("person.xml");
......
......@@ -35,6 +35,20 @@ public class XsltTest {
System.out.println(outputBaos.toString());
}
@Test
public void pageBreak_makesSpace() throws Exception {
String result = transform("page-break.xml");
assertXpathEvaluatesTo("before after ", "//field[@name='fulltext'][1]", result);
}
@Test
public void spaceLines_addsSpaceInText() throws Exception {
String result = transform("spaceLines_withText.xml");
assertXpathEvaluatesTo("myopener myparagraph ", "//field[@name='fulltext'][1]", result);
}
@Test
public void freeKeywords() throws Exception {
String result = transform("keywords_free.xml");
......
<?xml version="1.0" encoding="UTF-8"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0">
<teiHeader>
</teiHeader>
<text xml:id="my_id" xml:lang="ger">
<body>
<div>
<p>before <bibl><ref
target="http://bla.com"
>my link</ref></bibl> after</p>
</div>
</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>
</teiHeader>
<text xml:id="my_id" xml:lang="ger">
<body>
<div>
<p>before <hi
rendition="simple:underline">underlined</hi> <hi
rendition="simple:superscript">superscripted</hi> <hi
rendition="simple:italic">italicized</hi> after</p>
</div>
</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>
</teiHeader>
<text xml:id="my_id" xml:lang="ger">
<body>
<div>
<p>before <name type="object">my object</name> after</p>
</div>
</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>
</teiHeader>
<text xml:id="my_id" xml:lang="ger">
<body>
<div>
<p>before <seg xml:id="Z_1822-01-19_k_001">hiesigen <rs type="person"
ref="gnd:123">Mechanikers</rs></seg> after</p>
</div>
</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>
</teiHeader>
<text xml:id="my_id" xml:lang="ger">
<body>
<div>
<opener>myopener</opener>
<space unit="lines" quantity="2"/>
<p>myparagraph</p>
</div>
</body>
</text>
</TEI>
\ No newline at end of file
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