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

Add handling of unknown elements

parent 578904f9
......@@ -116,14 +116,14 @@
<field name="fulltext_html">
<xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
<div class="article">
<xsl:apply-templates select="*" mode="html_for_whole_article" />
<xsl:apply-templates mode="html_for_whole_article" />
</div>
<xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
</field>
</xsl:template>
<xsl:template match="body | div" mode="text_only">
<xsl:apply-templates select="*" mode="text_only"/>
<xsl:apply-templates mode="text_only"/>
</xsl:template>
<xsl:template match="p" mode="text_only">
......@@ -148,6 +148,33 @@
<!-- ++++++++++++ HTML +++++++++++++++++++ -->
<xsl:template match="*" mode="html_for_whole_article">
<xsl:if test=".//text()">
<xsl:message>
<xsl:text>Unknown element &lt;</xsl:text>
<xsl:value-of select="local-name()" />
<xsl:if test="@rend">
<xsl:text> rend="</xsl:text>
<xsl:value-of select="@rend" />
<xsl:text>"</xsl:text>
</xsl:if>
<xsl:if test="@type">
<xsl:text> type="</xsl:text>
<xsl:value-of select="@type" />
<xsl:text>"</xsl:text>
</xsl:if>
<xsl:text>&gt; - first occurrence: </xsl:text>
</xsl:message>
<span class="unknown-element">
<xsl:apply-templates mode="html_for_whole_article" />
</span>
</xsl:if>
</xsl:template>
<xsl:template match="body | div" mode="html_for_whole_article">
<xsl:apply-templates mode="html_for_whole_article"/>
</xsl:template>
<xsl:template match="opener" mode="html_for_whole_article">
<div class="opener">
......
......@@ -36,6 +36,13 @@ public class XsltHtmlTest {
System.out.println(outputBaos.toString());
}
@Test
public void unknownElement() throws Exception {
String html = transform("unknown-element.xml");
assertXpathEvaluatesTo("new stuff", "//span[@class='unknown-element']", html);
}
@Test
public void object() throws Exception {
String html = transform("object.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>
<some-unknown-element>new stuff</some-unknown-element>
</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