From badb20705d19da9b9498a031a0856280e633c234 Mon Sep 17 00:00:00 2001 From: "jwalden%mit.edu" Date: Tue, 29 Aug 2006 21:10:54 +0000 Subject: [PATCH] Bug 350442 - toXMLString omits namespace definition for attribute added with a namespace with an undefined prefix. r=brendan git-svn-id: svn://10.0.0.236/trunk@208751 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/js/src/jsxml.c | 50 +++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/mozilla/js/src/jsxml.c b/mozilla/js/src/jsxml.c index dd16cb86a5e..8722aa006a0 100644 --- a/mozilla/js/src/jsxml.c +++ b/mozilla/js/src/jsxml.c @@ -2784,31 +2784,6 @@ XMLToXMLString(JSContext *cx, JSXML *xml, const JSXMLArray *ancestorNSes, * faster code and less data overhead. */ - /* Step 17(c): append XML namespace declarations. */ - for (i = 0, n = decls.length; i < n; i++) { - ns2 = XMLARRAY_MEMBER(&decls, i, JSXMLNamespace); - JS_ASSERT(ns2->declared); - - js_AppendCString(&sb, " xmlns"); - - /* 17(c)(ii): NULL means *undefined* here. */ - if (!ns2->prefix) { - prefix = GeneratePrefix(cx, ns2->uri, &ancdecls); - if (!prefix) - goto out; - ns2->prefix = prefix; - } - - /* 17(c)(iii). */ - if (!IS_EMPTY(ns2->prefix)) { - js_AppendChar(&sb, ':'); - js_AppendJSString(&sb, ns2->prefix); - } - - /* 17(d-g). */ - AppendAttributeValue(cx, &sb, ns2->uri); - } - /* Step 17(b): append attributes. */ for (i = 0, n = xml->xml_attrs.length; i < n; i++) { attr = XMLARRAY_MEMBER(&xml->xml_attrs, i, JSXML); @@ -2854,6 +2829,31 @@ XMLToXMLString(JSContext *cx, JSXML *xml, const JSXMLArray *ancestorNSes, AppendAttributeValue(cx, &sb, attr->xml_value); } + /* Step 17(c): append XML namespace declarations. */ + for (i = 0, n = decls.length; i < n; i++) { + ns2 = XMLARRAY_MEMBER(&decls, i, JSXMLNamespace); + JS_ASSERT(ns2->declared); + + js_AppendCString(&sb, " xmlns"); + + /* 17(c)(ii): NULL means *undefined* here. */ + if (!ns2->prefix) { + prefix = GeneratePrefix(cx, ns2->uri, &ancdecls); + if (!prefix) + goto out; + ns2->prefix = prefix; + } + + /* 17(c)(iii). */ + if (!IS_EMPTY(ns2->prefix)) { + js_AppendChar(&sb, ':'); + js_AppendJSString(&sb, ns2->prefix); + } + + /* 17(d-g). */ + AppendAttributeValue(cx, &sb, ns2->uri); + } + /* Step 18: handle point tags. */ n = xml->xml_kids.length; if (n == 0) {