]> granicus.if.org Git - docbook-dsssl/commitdiff
Added remove-empty-div mode
authorNorman Walsh <ndw@nwalsh.com>
Sat, 21 Jun 2003 14:31:41 +0000 (14:31 +0000)
committerNorman Walsh <ndw@nwalsh.com>
Sat, 21 Jun 2003 14:31:41 +0000 (14:31 +0000)
xsl/html/html-rtf.xsl

index fccfbbceb1b5d48b03cc841ec4536ede4ba1711c..237bbcf4bbd373c6f36f4246030b5c3d2ac3daf7 100644 (file)
 
 <!-- ==================================================================== -->
 
+<!-- remove.empty.div mode templates remove empty blocks -->
+
+<xsl:template name="remove.empty.div">
+  <xsl:param name="div"/>
+  <xsl:choose>
+    <xsl:when test="function-available('exsl:node-set')">
+      <xsl:apply-templates select="exsl:node-set($div)" mode="remove.empty.div"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:copy-of select="$div"/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template xmlns:html="http://www.w3.org/1999/xhtml"
+              match="html:p|p|html:div|div" mode="remove.empty.div">
+  <xsl:if test="node()">
+    <xsl:copy>
+      <xsl:copy-of select="@*"/>
+      <xsl:apply-templates mode="remove.empty.div"/>
+    </xsl:copy>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template match="*" mode="remove.empty.div">
+  <xsl:copy>
+    <xsl:copy-of select="@*"/>
+    <xsl:apply-templates mode="remove.empty.div"/>
+  </xsl:copy>
+</xsl:template>
+
+<xsl:template match="text()|processing-instruction()|comment()" mode="remove.empty.div">
+  <xsl:copy/>
+</xsl:template>
+
+<!-- ==================================================================== -->
+
 </xsl:stylesheet>