Re: importNode missing namespace

Michael Glavassevich <[email protected]> Fri, 13 Mar 2009 00:33:44 -0400
Newsgroups gmane.text.xml.commons.devel
Message-ID <OF4D4D8250.E7CC039F-ON85257578.00184597-85257578.0018E8D5@ca.ibm.com>
Richard <[email protected]> wrote on 03/13/2009 12:20:42 AM:

> Hi, I got such problem with importNode, when try to import a Node
> from one Document into another.
>
> DocumentA
> <?xml version='1.0' encoding='utf-8'?><m:root xmlns:m='TEST'><m:
> s>TEST</m:s></m:root>
> DocumentB:
> <?xml version='1.0' encoding='utf-8' ?><n:root xmlns:n='TEST'><n:
> t>TEST</n:t></n:root>
>
> I try to import m:s in DocumentA into DocumentB, and replace n:t Node
>
> expected:
> <?xml version='1.0' encoding='utf-8' ?><n:root xmlns:n='TEST'><n:
> s>TEST</n:s></n:root>
>
> but the result was:
> <?xml version='1.0' encoding='utf-8' ?><n:root xmlns:n='TEST'><m:
> s>TEST</m:s></n:root>
>
> Can somebody tell me why?

You've left out all sorts of details, but you're probably not using a
namespace-aware or namespace fixing serializer when you serialize the
document. DOM Level 3's LSSerializer would write [1] this out correctly.

Thanks.

[1]
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/namespaces-algorithms.html#normalizeDocumentAlgo

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [email protected]
E-mail: [email protected]