xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tom Wnuk" <tw...@earthlink.net>
Subject RE: importNode() Problem
Date Fri, 05 May 2000 17:14:41 GMT
Well, I have resolved my problem.

Whether it is suppose to work like this I'm no longer sure.  After reading
the DOM spec again for importNode(), it doesn't say that it will actually
update the target DOM via the import process.  My understanding is that it
simply returns the node which is now owned by the target DOM.  This may be a
side-effect but it's enough to allow me to place this node in the target DOM
as opposed to letting the import just append it.  It actually saves me from
having to build a new DOM, now I can simply call replaceNode() instead.

If I'm assuming in error or have made a big mistake, please let me know.

Thanks again for everyone's help.
Tom


>  -----Original Message-----
> From: 	Tom Wnuk [mailto:twnuk@earthlink.net] 
> Sent:	Friday, May 05, 2000 9:18 AM
> To:	Apache XML General-Help
> Subject:	RE: importNode() Problem
> 
> Thank-you so much for responding so quickly.  I tried adding cloneNode()
> but unfortunately it didn't correct the problem.
> 
> I'm at a loss and I really don't want to code another solution since
> you've already done it.  
> 
> Any other ideas would be most appreciated.
> 
> Thanks
> Tom
> 
> Tom Wnuk
> 
> 
> 	 -----Original Message-----
> 	From: 	Linda Derezinski [mailto:linda@interfacecontrol.com] 
> 	Sent:	Friday, May 05, 2000 8:19 AM
> 	To:	general@xml.apache.org; twnuk@earthlink.net
> 	Subject:	RE: importNode() Problem
> 
> 	The node passed to importnode cannot have a parent.  In your
> example, node is a member of document sXML1.
> 	Just missing the call to cloneNode().
> 
> 
> 		Node newNode = node.cloneNode (true);
> 	            doc2.importNode(newNode, true);
> 
> 	- Linda Derezinski
> 		 -----Original Message-----
> 		From: 	Tom Wnuk [mailto:twnuk@earthlink.net] 
> 		Sent:	Friday, May 05, 2000 11:00 AM
> 		To:	Apache XML General-Help
> 		Subject:	importNode() Problem
> 
> 		I'm trying to utilize importNode() as defined below.  I'm
> using xerces v1.0.3 and the it appears the importNode is not working.  
> 
> 		What am I doing wrong?
> 
> 		==================
> 		        String sXML1 = "<?xml version=\"1.0\" ?>" +
> 	
> "<TEST><ResponseType>XML</ResponseType>" +
> 		                        "<StyleSheet>login.xsl</StyleSheet>"
> +
> 		                        "</TEST>";
> 		                        
> 		        try
> 		        {
> 		            Document doc1 = XMLHelper.getDocument(sXML1);
> 				    Element eRoot =
> doc1.getDocumentElement();        
> 		            NodeList nlTmp =
> eRoot.getElementsByTagName("ResponseType");
> 		            Node node = nlTmp.item(0);
> 		            
> 		            Document doc2 = XMLHelper.getDocument();
> 				    Element eNewRoot  =
> doc2.createElement("TEST");
> 				    doc2.appendChild(eNewRoot);		
> 		            
> 		            doc2.importNode(node, true);
> 		            
> 		            String sDoc2 =
> XMLHelper.makeStringFromDOM(doc2);
> 		            
> 		            System.out.println("sDoc=\n" + sDoc2);
> 		        }
> 
> 		==================
> 
> 		Thanks 
> 		Tom
> 
> 		Tom Wnuk
> 		twnuk@earthlink.net
> 		twnuk@hotmail.com
> 		 << File: ATT00006.txt >>  << File: ATT00031.txt >> 

Mime
View raw message