]> granicus.if.org Git - docbook-dsssl/commitdiff
Added <xsl:template match="/"> to make stripns.xsl usable as a
authorMichael Smith <xmldoc@users.sourceforge.net>
Thu, 23 Mar 2006 23:13:37 +0000 (23:13 +0000)
committerMichael Smith <xmldoc@users.sourceforge.net>
Thu, 23 Mar 2006 23:13:37 +0000 (23:13 +0000)
standalone stylesheet for stripping out DocBook 5/NG to DocBook 4.
Note that DocBook XSLT drivers that include this stylesheet all
override the match="/" template.

xsl/common/stripns.xsl

index 0ed6255f3389d183fe232bf7ba59b349869184d9..c5fe643959d01c7273c942354a138f5a789700d3 100644 (file)
@@ -3,7 +3,8 @@
                xmlns:ng="http://docbook.org/docbook-ng"
                xmlns:db="http://docbook.org/ns/docbook"
                 xmlns:saxon="http://icl.com/saxon"
-                exclude-result-prefixes="db ng saxon"
+                xmlns:exsl="http://exslt.org/common"
+                exclude-result-prefixes="db ng exsl saxon"
                 version='1.0'>
 
 <xsl:template match="*" mode="stripNS">
   <xsl:copy/>
 </xsl:template>
 
+<xsl:template match="/">
+  <xsl:choose>
+    <xsl:when test="function-available('exsl:node-set')
+                    and (*/self::ng:* or */self::db:*)">
+      <xsl:message>Stripping NS from DocBook 5/NG document.</xsl:message>
+      <xsl:variable name="nons">
+        <xsl:apply-templates mode="stripNS"/>
+      </xsl:variable>
+      <xsl:message>Processing stripped document.</xsl:message>
+      <xsl:apply-templates select="exsl:node-set($nons)"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:copy-of select="@* | node()"/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
 </xsl:stylesheet>