fixed bug #127561 (xsl:element with a 'computed' namespace attribute)
authorWilliam M. Brack <wbrack@src.gnome.org>
Fri, 21 Nov 2003 17:00:22 +0000 (17:00 +0000)
committerWilliam M. Brack <wbrack@src.gnome.org>
Fri, 21 Nov 2003 17:00:22 +0000 (17:00 +0000)
* libxslt/transform.c: fixed bug #127561 (xsl:element with a
  'computed' namespace attribute)
* tests/docs/Makefile.am tests/docs/bug-136.xml
  tests/general/Makefile.am tests/docs/bug-136*: added tests
  to the regression for bug #127561

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

index 4a95cd3..a9c3cfc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Sat Nov 22 00:53:47 HKT 2003 William Brack <wbrack@mmm.com.hk>
+
+       * libxslt/transform.c: fixed bug #127561 (xsl:element with a
+         'computed' namespace attribute)
+       * tests/docs/Makefile.am tests/docs/bug-136.xml
+         tests/general/Makefile.am tests/docs/bug-136*: added tests
+         to the regression for bug #127561
+
 Fri Nov 21 18:17:32 HKT 2003 William Brack <wbrack@mmm.com.hk>
 
        * libxslt/keys.c: small further enhancement, bug #127450
index 8e0bcc6..dc730c3 100644 (file)
@@ -2501,6 +2501,18 @@ xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node,
        name = ncname;
     }
 
+    /*
+     * Create the new element
+     */
+    copy = xmlNewDocNode(ctxt->output, NULL, name, NULL);
+    if (copy == NULL) {
+       xsltTransformError(ctxt, NULL, inst,
+           "xsl:element : creation of %s failed\n", name);
+       goto error;
+    }
+    xmlAddChild(ctxt->insert, copy);
+    ctxt->insert = copy;
+
     if ((comp->ns == NULL) && (comp->has_ns)) {
        namespace = xsltEvalAttrValueTemplate(ctxt, inst,
                (const xmlChar *)"namespace", XSLT_NAMESPACE);
@@ -2532,30 +2544,25 @@ xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node,
        }
     }
 
-    copy = xmlNewDocNode(ctxt->output, ns, name, NULL);
-    if (copy == NULL) {
-       xsltTransformError(ctxt, NULL, inst,
-           "xsl:element : creation of %s failed\n", name);
-       goto error;
-    }
     if (generateDefault == 1) {
        xmlNsPtr defaultNs = NULL;
 
-       if ((ctxt->insert != NULL) && (ctxt->insert->type == XML_ELEMENT_NODE))
-           defaultNs = xmlSearchNs(ctxt->insert->doc, ctxt->insert, NULL);
+       if ((oldInsert != NULL) && (oldInsert->type == XML_ELEMENT_NODE))
+           defaultNs = xmlSearchNs(oldInsert->doc, oldInsert, NULL);
        if ((defaultNs == NULL) || (!xmlStrEqual(defaultNs->href, comp->ns))) {
-           ns = xmlNewNs(copy, comp->ns, NULL);
-           copy->ns = ns;
+           ns = xmlNewNs(ctxt->insert, comp->ns, NULL);
+           ctxt->insert->ns = ns;
        } else {
-           copy->ns = defaultNs;
+           ctxt->insert->ns = defaultNs;
        }
     } else if ((ns == NULL) && (oldns != NULL)) {
        /* very specific case xsltGetNamespace failed */
-        ns = xmlNewNs(copy, oldns->href, oldns->prefix);
-       copy->ns = ns;
-    }
-    xmlAddChild(ctxt->insert, copy);
-    ctxt->insert = copy;
+        ns = xmlNewNs(ctxt->insert, oldns->href, oldns->prefix);
+       ctxt->insert->ns = ns;
+    } else
+        ctxt->insert->ns = ns;
+
+
     if (comp->has_use) {
        if (comp->use != NULL) {
            xsltApplyAttributeSet(ctxt, node, inst, comp->use);
index d48a31c..6887497 100644 (file)
@@ -135,6 +135,7 @@ EXTRA_DIST =        \
        bug-133.xml \
        bug-134.xml \
        bug-135.xml \
+       bug-136.xml \
        character.xml \
        array.xml \
        items.xml
diff --git a/tests/docs/bug-136.xml b/tests/docs/bug-136.xml
new file mode 100644 (file)
index 0000000..af34d2b
--- /dev/null
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<test>
+ <item n="http://some/namespace/uri" />
+</test>
index 09ac805..6693c2f 100644 (file)
@@ -141,6 +141,7 @@ EXTRA_DIST = \
     bug-133.out bug-133.xsl \
     bug-134.out bug-134.xsl \
     bug-135.out bug-135.xsl \
+    bug-136.out bug-136.xsl \
     character.out character.xsl \
     character2.out character2.xsl \
     itemschoose.out itemschoose.xsl \
diff --git a/tests/general/bug-136.out b/tests/general/bug-136.out
new file mode 100644 (file)
index 0000000..8016df3
--- /dev/null
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+
+ <ns1:foobar xmlns:ns1="http://some/namespace/uri"/>
+
diff --git a/tests/general/bug-136.xsl b/tests/general/bug-136.xsl
new file mode 100644 (file)
index 0000000..e06b353
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<xsl:stylesheet version="1.0" 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
+<xsl:template match="item">
+    <xsl:element name="foobar" namespace="{@n}" />
+</xsl:template>
+</xsl:stylesheet>
+