-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Namespace propagation is not correct on serialization #247
Comments
Wouldn't a second |
No, because that namespace declaration applies only to the |
Oh for some reason I was reading that completely backwards; yeah, the specified XMLDOM output isn't correct. |
I found that commented code https://github.com/jindw/xmldom/blob/master/dom.js#L1042-L1043 If uncomment that code it works fine Example 1const doc = new DOMImplementation().createDocument(null, "root");
doc.documentElement.appendChild(doc.createElement("child"));
const signature1 = doc.createElementNS("https://signature.com", "Signature");
doc.documentElement.appendChild(signature1);
const signature2 = doc.createElementNS("https://signature.com", "Signature");
doc.documentElement.appendChild(signature2);
const xml = new XMLSerializer().serializeToString(doc);
console.log(xml);
// Output
// <root>
// <child/>
// <Signature xmlns="https://signature.com"/>
// <Signature xmlns="https://signature.com"/>
// </root> Example 2const doc = new DOMImplementation().createDocument(null, "root");
const p1First = doc.createElementNS("http//first.namespace.com", "p1:first");
const p2Second = doc.createElementNS("http//second.namespace.com", "p2:second");
const p1Third = doc.createElementNS("http//first.namespace.com", "p1:third");
const p2Fourth = doc.createElementNS("http//second.namespace.com", "p2:fourth");
doc.documentElement.appendChild(p1First);
p1First.appendChild(p2Second)
p1First.appendChild(p1Third)
p1Third.appendChild(p2Fourth)
const xml = new XMLSerializer().serializeToString(doc);
console.log(xml);
// Output
// <root>
// <p1:first xmlns:p1="http//first.namespace.com">
// <p2:second xmlns:p2="http//second.namespace.com"/>
// <p1:third>
// <p2:fourth xmlns:p2="http//second.namespace.com"/>
// </p1:third>
// </p1:first>
// </root> |
I use this app to generate XML document.
fourth
element in generated XML doesn't havexmlns:p2="http//second.namespace.com"
XMLDOM output:
Chrome output:
The text was updated successfully, but these errors were encountered: