changed to assure comment which preceeds root node is output after DTD
authorWilliam M. Brack <wbrack@src.gnome.org>
Mon, 12 Jan 2004 16:36:42 +0000 (16:36 +0000)
committerWilliam M. Brack <wbrack@src.gnome.org>
Mon, 12 Jan 2004 16:36:42 +0000 (16:36 +0000)
* libxslt/transform.c: changed to assure comment which
  preceeds root node is output after DTD (Bug 130433)
* test/exslt/common/node-set.4.*: added test case for
  Bug 130922

ChangeLog
libxslt/transform.c
tests/exslt/common/Makefile.am
tests/exslt/common/node-set.4.out [new file with mode: 0644]
tests/exslt/common/node-set.4.xml [new file with mode: 0644]
tests/exslt/common/node-set.4.xsl [new file with mode: 0644]

index 7e561de..9dd53d9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Tue Jan 13 00:33:50 HKT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/transform.c: changed to assure comment which
+         preceeds root node is output after DTD (Bug 130433)
+       * test/exslt/common/node-set.4.*: added test case for
+         Bug 130922
+
 Mon Jan 12 12:51:45 HKT 2004 William Brack <wbrack@mmm.com.hk>
 
        * doc/site.xsl: Changed logo spacing to avoid stacking
index fe39651..c134337 100644 (file)
@@ -3855,7 +3855,7 @@ xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc,
 {
     xmlDocPtr res = NULL;
     xsltTransformContextPtr ctxt = NULL;
-    xmlNodePtr root;
+    xmlNodePtr root, node;
     const xmlChar *method;
     const xmlChar *doctypePublic;
     const xmlChar *doctypeSystem;
@@ -4068,11 +4068,17 @@ xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc,
         }
         if (ctxt->type == XSLT_OUTPUT_XML) {
             XSLT_GET_IMPORT_PTR(doctypePublic, style, doctypePublic)
-                XSLT_GET_IMPORT_PTR(doctypeSystem, style, doctypeSystem)
-                if (((doctypePublic != NULL) || (doctypeSystem != NULL)))
+            XSLT_GET_IMPORT_PTR(doctypeSystem, style, doctypeSystem)
+            if (((doctypePublic != NULL) || (doctypeSystem != NULL))) {
+               /* Need a small "hack" here to assure DTD comes before
+                  possible comment nodes */
+               node = res->children;
+               res->children = NULL;
                 res->intSubset = xmlCreateIntSubset(res, root->name,
                                                     doctypePublic,
                                                     doctypeSystem);
+               res->children->next = node;
+           }
         }
     }
     xmlXPathFreeNodeSet(ctxt->nodeList);
index 42287ee..759f27a 100644 (file)
@@ -7,6 +7,7 @@ EXTRA_DIST =                                            \
        node-set.1.xml node-set.1.xsl node-set.1.out    \
        node-set.2.xml node-set.2.xsl node-set.2.out    \
        node-set.3.xml node-set.3.xsl node-set.3.out    \
+       node-set.4.xml node-set.4.xsl node-set.4.out    \
        object-type.1.xml object-type.1.xsl object-type.1.out \
        import-test1a.imp import-test1b.imp import-test1.out \
        import-test1.xml import-test1.xsl
diff --git a/tests/exslt/common/node-set.4.out b/tests/exslt/common/node-set.4.out
new file mode 100644 (file)
index 0000000..4295f03
--- /dev/null
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<initial>Mode of FOO is input</initial><post-transform>Mode of FOO is fiddled</post-transform>
diff --git a/tests/exslt/common/node-set.4.xml b/tests/exslt/common/node-set.4.xml
new file mode 100644 (file)
index 0000000..1464b0d
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:exsl="http://exslt.org/common"
+                version="1.0">
+
+<xsl:key name="tmpls" match="xsl:template" use="@name"/>
+
+<xsl:template match="/">
+  <xsl:message>
+    <xsl:text>Mode of FOO is </xsl:text>
+    <xsl:value-of select="key('tmpls', 'FOO')/@mode"/>
+  </xsl:message>
+
+  <xsl:variable name="fiddle">
+    <xsl:apply-templates select="//xsl:template"/>
+  </xsl:variable>
+
+  <xsl:apply-templates select="exsl:node-set($fiddle)" mode="faddle"/>
+</xsl:template>
+
+<xsl:template match="xsl:template">
+  <xsl:copy>
+    <xsl:copy-of select="@*"/>
+    <xsl:attribute name="mode">fiddled</xsl:attribute>
+  </xsl:copy>
+</xsl:template>
+
+<xsl:template match="/" mode="faddle">
+  <xsl:message>
+    <xsl:text>Mode of FOO is </xsl:text>
+    <xsl:value-of select="key('tmpls', 'FOO')/@mode"/>
+  </xsl:message>
+</xsl:template>
+
+<xsl:template name="FOO" mode="input"/>
+
+</xsl:stylesheet>
diff --git a/tests/exslt/common/node-set.4.xsl b/tests/exslt/common/node-set.4.xsl
new file mode 100644 (file)
index 0000000..50c976c
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:exsl="http://exslt.org/common"
+                version="1.0">
+
+<xsl:key name="tmpls" match="xsl:template" use="@name"/>
+
+<xsl:template match="/">
+  <xsl:element name="initial">
+    <xsl:text>Mode of FOO is </xsl:text>
+    <xsl:value-of select="key('tmpls', 'FOO')/@mode"/>
+  </xsl:element>
+
+  <xsl:variable name="fiddle">
+    <xsl:apply-templates select="//xsl:template"/>
+  </xsl:variable>
+
+  <xsl:apply-templates select="exsl:node-set($fiddle)" mode="faddle"/>
+</xsl:template>
+
+<xsl:template match="xsl:template">
+  <xsl:copy>
+    <xsl:copy-of select="@*"/>
+    <xsl:attribute name="mode">fiddled</xsl:attribute>
+  </xsl:copy>
+</xsl:template>
+
+<xsl:template match="/" mode="faddle">
+  <xsl:element name="post-transform">
+    <xsl:text>Mode of FOO is </xsl:text>
+    <xsl:value-of select="key('tmpls', 'FOO')/@mode"/>
+  </xsl:element>
+</xsl:template>
+
+<xsl:template name="FOO" mode="input"/>
+
+</xsl:stylesheet>