fixed bug #87279 added an example in the regression tests for this case
authorDaniel Veillard <veillard@src.gnome.org>
Fri, 5 Jul 2002 16:37:21 +0000 (16:37 +0000)
committerDaniel Veillard <veillard@src.gnome.org>
Fri, 5 Jul 2002 16:37:21 +0000 (16:37 +0000)
* libxslt/preproc.c libxslt/transform.c: fixed bug #87279
* tests/docs/Makefile.am tests/docs/bug-88.xml
  tests/general/Makefile.am tests/general/bug-88.*: added an
  example in the regression tests for this case
Daniel

ChangeLog
libxslt/preproc.c
libxslt/transform.c
tests/docs/Makefile.am
tests/docs/bug-88.xml [new file with mode: 0644]
tests/general/Makefile.am
tests/general/bug-88.out [new file with mode: 0644]
tests/general/bug-88.xsl [new file with mode: 0644]

index 24a8ba6..d830d6f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Fri Jul  5 18:28:08 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+       * libxslt/preproc.c libxslt/transform.c: fixed bug #87279
+       * tests/docs/Makefile.am tests/docs/bug-88.xml
+         tests/general/Makefile.am tests/general/bug-88.*: added an
+         example in the regression tests for this case
+
 Fri Jul  5 16:30:02 CEST 2002 Daniel Veillard <daniel@veillard.com>
 
        * libxslt/preproc.c libxslt/xsltutils.c: applied a patch from
index dc613d8..a52f193 100644 (file)
@@ -453,7 +453,15 @@ xsltElementComp(xsltStylesheetPtr style, xmlNodePtr inst) {
     comp->ns = xsltEvalStaticAttrValueTemplate(style, inst,
                         (const xmlChar *)"namespace",
                         XSLT_NAMESPACE, &comp->has_ns);
+    if (comp->has_ns == 0) {
+       xmlNsPtr defaultNs;
 
+       defaultNs = xmlSearchNs(inst->doc, inst, NULL);
+       if (defaultNs != NULL) {
+           comp->ns = xmlStrdup(defaultNs->href);
+           comp->has_ns = 1;
+       }
+    }
     comp->use = xsltEvalStaticAttrValueTemplate(style, inst,
                       (const xmlChar *)"use-attribute-sets",
                       XSLT_NAMESPACE, &comp->has_use);
index 1891f0b..da226af 100644 (file)
@@ -2124,6 +2124,7 @@ xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node,
     xmlNsPtr ns = NULL, oldns = NULL;
     xmlNodePtr copy;
     xmlNodePtr oldInsert;
+    int generateDefault = 0;
 
 
     if (ctxt->insert == NULL)
@@ -2166,6 +2167,8 @@ xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node,
                                         ctxt->insert);
            xmlFree(namespace);
        }
+    } else if ((comp->ns != NULL) && (prefix == NULL) && (comp->has_ns)) {
+       generateDefault = 1;
     } else if (comp->ns != NULL) {
        ns = xsltGetSpecialNamespace(ctxt, inst, comp->ns, prefix,
                                     ctxt->insert);
@@ -2195,7 +2198,10 @@ xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node,
            "xsl:element : creation of %s failed\n", name);
        goto error;
     }
-    if ((ns == NULL) && (oldns != NULL)) {
+    if (generateDefault == 1) {
+        ns = xmlNewNs(copy, comp->ns, NULL);
+       copy->ns = ns;
+    } else if ((ns == NULL) && (oldns != NULL)) {
        /* very specific case xsltGetNamespace failed */
         ns = xmlNewNs(copy, oldns->href, oldns->prefix);
        copy->ns = ns;
index 1a431b4..e526251 100644 (file)
@@ -87,6 +87,7 @@ EXTRA_DIST =  \
        bug-84.xml \
        bug-86.xml \
        bug-87.xml \
+       bug-88.xml \
        character.xml \
        array.xml \
        items.xml
diff --git a/tests/docs/bug-88.xml b/tests/docs/bug-88.xml
new file mode 100644 (file)
index 0000000..69d62f2
--- /dev/null
@@ -0,0 +1 @@
+<doc/>
index ba08ab0..bed8e01 100644 (file)
@@ -90,6 +90,7 @@ EXTRA_DIST = \
     bug-84.out bug-84.xsl \
     bug-86.out bug-86.xsl \
     bug-87.out bug-87.xsl \
+    bug-88.out bug-88.xsl \
     character.out character.xsl \
     character2.out character2.xsl \
     itemschoose.out itemschoose.xsl \
diff --git a/tests/general/bug-88.out b/tests/general/bug-88.out
new file mode 100644 (file)
index 0000000..ce11146
--- /dev/null
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<test xmlns="http://bar.xml"/>
diff --git a/tests/general/bug-88.xsl b/tests/general/bug-88.xsl
new file mode 100644 (file)
index 0000000..a2cc734
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+  <xsl:template match="/">
+    <xsl:element xmlns="http://bar.xml" name="test"/>
+  </xsl:template>
+</xsl:stylesheet>