Altova Mailing List Archives


Re: importing a node and resolving namespace prefixes

From: "Joe Fawcett" <joefawcett@---------.------>
To: NULL
Date: 9/2/2006 9:13:00 AM

You can't directly. You will have to recreate the nodes in the new document 
based on the local name of the elements, the new namespace and any text node 
values etc.
This sort of problem is usually solved more easily by XSLT, especially if 
you can use version 2.0 which has better namespace handling options.

-- 

Joe Fawcett -  XML MVP


http://joe.fawcett.name
"K Lao" <KLao@d...> wrote in message 
news:32F1DD6C-C37C-4C81-BEED-5C7004D3D032@m......
>I am using IXMLDOMDocument3's importNode() and appendchild() to copy a node
> from one XML document to another.  However, the node being copied (deep 
> copy)
> still uses the namespace prefixes of the source doc.  How do I make the 
> node
> copied to the dest doc use the dest doc's namespace prefixes?
>
> Example:
>
> Source XML:
> <?xml version="1.0" encoding="UTF-8"?>
> <psf:PrintTicket
> xmlns:psf="http://schemas.microsoft.com/windows/2003/08/printing/printschemaframework"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1"
> xmlns:ns0000="http://schemas.something.com"
> xmlns:psk="http://schemas.microsoft.com/windows/2003/08/printing/printschemakeywords">
> <psf:Feature name="psk:JobOutputBin">
>  <psf:Option name="ns0000:DestPrinterDefault"/>
> </psf:Feature>
> </psf:PrintTicket>
>
> Destination:
> <?xml version="1.0" encoding="UTF-8"?>
> <psf:PrintTicket
> xmlns:psf="http://schemas.microsoft.com/windows/2003/08/printing/printschemaframework"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1"
> xmlns:ns0000="http://schemas.something.com"
> xmlns:kxd000="http://schemas.microsoft.com/windows/2003/08/printing/printschemakeywords">
> </psf:PrintTicket>
>
> Note that the namespace prefix psk in Source XML is now kxd000 in the Dest 
> XML
>
> Result I am getting:
> <?xml version="1.0" encoding="UTF-8"?>
> <psf:PrintTicket
> xmlns:psf="http://schemas.microsoft.com/windows/2003/08/printing/printschemaframework"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1"
> xmlns:ns0000="http://schemas.something.com"
> xmlns:kxd000="http://schemas.microsoft.com/windows/2003/08/printing/printschemakeywords">
> <psf:Feature name="psk:JobOutputBin">
>  <psf:Option name="ns0000:DestPrinterDefault"/>
> </psf:Feature>
> </psf:PrintTicket>
>
> The namespace prefixes are not resolved.
>
> What can I do to fix this? 


Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.