Fix last I5 validity errors
and remove empty texts
diff --git a/xslt/epub2i5.xsl b/xslt/epub2i5.xsl
index 23f452a..b72c1c4 100644
--- a/xslt/epub2i5.xsl
+++ b/xslt/epub2i5.xsl
@@ -439,11 +439,13 @@
</xsl:template>
<xsl:template match="xhtml:body/xhtml:a">
- <p>
- <ref target="{@href}">
- <xsl:apply-templates />
- </ref>
- </p>
+ <xsl:if test="normalize-space(.)">
+ <p>
+ <ref target="{@href}">
+ <xsl:apply-templates />
+ </ref>
+ </p>
+ </xsl:if>
</xsl:template>
<xsl:template match="xhtml:body/xhtml:span">
@@ -463,9 +465,11 @@
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="xhtml:a">
- <ref target="{@href}">
- <xsl:apply-templates />
- </ref>
+ <xsl:if test="normalize-space(.)">
+ <ref target="{@href}">
+ <xsl:apply-templates />
+ </ref>
+ </xsl:if>
</xsl:template>
<xsl:template match="xhtml:br"/>
diff --git a/xslt/pass2.xsl b/xslt/pass2.xsl
index 9aef8ca..49af02f 100644
--- a/xslt/pass2.xsl
+++ b/xslt/pass2.xsl
@@ -9,14 +9,17 @@
<xsl:mode on-no-match="shallow-copy"/>
+ <xsl:template match="p[not(normalize-space())]" priority="1.0"/>
- <xsl:template match="p[descendant::div|descendant::p]" priority="1.0">
+ <xsl:template match="div[not(normalize-space())]" priority="1.0"/>
+
+ <xsl:template match="p[descendant::div|descendant::p]" priority="0.9">
<div type="section">
<xsl:apply-templates/>
</div>
</xsl:template>
- <xsl:template match="(ref|emph|hi|text())[parent::div]" priority="1.0">
+ <xsl:template match="(ref|emph|hi|text())[parent::div]" priority="0.9">
<p>
<xsl:apply-templates/>
</p>