You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Minimol M <m....@gmail.com> on 2007/09/28 12:36:04 UTC
Namespace definitions also appearing with the node when using importNode.
Hi,
I used the following code to import a node (along with child nodes) from a
document to another
DOMElement* tempNode =
(DOMElement*)doc->importNode(messageHandler->currentNode, true);
currentNode = currentNode->appendChild(tempNode);
(currentNode is DOMNode*).
But when I saw the result, the namespace definitions also are appearing in
the node and its child nodes. these definitions are already there in the
root node of destination document.
source node to be imported
----------------------------------------
<jobBody>
<requestType>activateConnection</requestType>
<jobType>provide</jobType>
<connectionType>BB IPStream</connectionType>
<pSIService>
<S97:serviceId>VLAN BB MJ AGG</S97:serviceId>
<S97:serviceName>TestVLAN_BB</S97:serviceName>
<S97:serviceDescription>00034</S97:serviceDescription>
</pSIService>
after import, the node in the destination document look like this:
---------------------------------------------------------------------------------------------
<jobBody xmlns="
http://itprogrammes.intra.xxx.com/pdb/capabilities/ManageDaaliResource/2005/11/16
">
<requestType>activateConnection</requestType>
<jobType>provide</jobType>
<connectionType>BB IPStream</connectionType>
<pSIService>
<S97:serviceId xmlns:S97="
http://ccm.intra.xxx.com/2005/11/16/LIB/Info/CCM/AnalysisModel/Services">VLAN<http://ccm.intra.xxx.com/2005/11/16/LIB/Info/CCM/AnalysisModel/Services%22%3EVLAN>BB
MJ AGG</S97:serviceId>
<S97:serviceName
xmlns:S97="http://ccm.intra.xxx.com/2005/11/16/LIB/Info/CCM/AnalysisModel/Services">TestVLAN_BB</S97:serviceName
<http://ccm.intra.xxx.com/2005/11/16/LIB/Info/CCM/AnalysisModel/Services%22%3ETestVLAN_BB%3C/S97:serviceName>
>
<S97:serviceDescription
xmlns:S97="http://ccm.intra.xxx.com/2005/11/16/LIB/Info/CCM/AnalysisModel/Services">00034</S97:serviceDescription
<http://ccm.intra.xxx.com/2005/11/16/LIB/Info/CCM/AnalysisModel/Services%22%3E00034%3C/S97:serviceDescription>
>
</pSIService>
How can I suppress these namespace definitions so that I get the desired
output? Appreciate if anybody can give a quick info.
Thanks and Regards
Mini.
Re: Namespace definitions also appearing with the node when using importNode.
Posted by Boris Kolpackov <bo...@codesynthesis.com>.
Hi,
The nodes that you import use S97 as a namespace prefix while the target
document sets this namespace as default. DOM considers namespace prefixes
in element names important and preserves them. If you want the imported
fragment to use the namespace declaration from the root element, you will
need to make sure the same prefix is used in both places.
Boris
--
Boris Kolpackov
Code Synthesis Tools CC
http://www.codesynthesis.com
Open-Source, Cross-Platform C++ XML Data Binding
RE: Namespace definitions also appearing with the node when using importNode.
Posted by Jesse Pelton <js...@PKC.com>.
Can you attach complete sample source and result documents? Even if the
root node declares the namespace properly, it's possible that
intervening levels of the hierarchy change it.
-----Original Message-----
From: Minimol M [mailto:m.minimol@gmail.com]
Sent: Friday, September 28, 2007 6:36 AM
To: c-users@xerces.apache.org
Subject: Namespace definitions also appearing with the node when using
importNode.
Hi,
I used the following code to import a node (along with child nodes) from
a
document to another
DOMElement* tempNode =
(DOMElement*)doc->importNode(messageHandler->currentNode, true);
currentNode = currentNode->appendChild(tempNode);
(currentNode is DOMNode*).
But when I saw the result, the namespace definitions also are appearing
in
the node and its child nodes. these definitions are already there in
the
root node of destination document.
source node to be imported
----------------------------------------
<jobBody>
<requestType>activateConnection</requestType>
<jobType>provide</jobType>
<connectionType>BB IPStream</connectionType>
<pSIService>
<S97:serviceId>VLAN BB MJ AGG</S97:serviceId>
<S97:serviceName>TestVLAN_BB</S97:serviceName>
<S97:serviceDescription>00034</S97:serviceDescription>
</pSIService>
after import, the node in the destination document look like this:
------------------------------------------------------------------------
---------------------
<jobBody xmlns="
http://itprogrammes.intra.xxx.com/pdb/capabilities/ManageDaaliResource/2
005/11/16
">
<requestType>activateConnection</requestType>
<jobType>provide</jobType>
<connectionType>BB IPStream</connectionType>
<pSIService>
<S97:serviceId xmlns:S97="
http://ccm.intra.xxx.com/2005/11/16/LIB/Info/CCM/AnalysisModel/Services"
>VLAN<http://ccm.intra.xxx.com/2005/11/16/LIB/Info/CCM/AnalysisModel/Ser
vices%22%3EVLAN>BB
MJ AGG</S97:serviceId>
<S97:serviceName
xmlns:S97="http://ccm.intra.xxx.com/2005/11/16/LIB/Info/CCM/AnalysisMode
l/Services">TestVLAN_BB</S97:serviceName
<http://ccm.intra.xxx.com/2005/11/16/LIB/Info/CCM/AnalysisModel/Services
%22%3ETestVLAN_BB%3C/S97:serviceName>
>
<S97:serviceDescription
xmlns:S97="http://ccm.intra.xxx.com/2005/11/16/LIB/Info/CCM/AnalysisMode
l/Services">00034</S97:serviceDescription
<http://ccm.intra.xxx.com/2005/11/16/LIB/Info/CCM/AnalysisModel/Services
%22%3E00034%3C/S97:serviceDescription>
>
</pSIService>
How can I suppress these namespace definitions so that I get the desired
output? Appreciate if anybody can give a quick info.
Thanks and Regards
Mini.