Append child node

hello,

I am tring to update the node in the existing document.

This is source code
<%@ page language=“java” import =“java.io." %>
<%@ page import ="org.w3c.dom.
” %>
<%@ page import =“javax.xml.parsers." %>
<%@ page import ="com.softwareag.tamino.api.dom.
” %>
<%
TaminoClient tamino= null;
try{
System.out.println(“Ok”);
File fin = new File(“test.xml”);
DocumentBuilderFactory Dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder bd = Dbf.newDocumentBuilder();
org.w3c.dom.Document md=bd.parse(fin);
String QueryVal="//root[login/username='shan’and login/password=‘thi’]";
Element ele = md.getDocumentElement();
System.out.println(ele.getNodeName());
Node newNode =md.getElementsByTagName(ele.getNodeName()).item(0);
tamino=new TaminoClient(“http://localhost/tamino/tempa/data1”);
tamino.startSession();
TaminoResult tr3= tamino.query(QueryVal);
Element item= (Element)tr3.getElement().getFirstChild();
Node oldNode = item.getElementsByTagName(ele.getNodeName()).item(0);
oldNode.appendChild(newNode.getChildNodes().item(0));
TaminoResult tr1 = tamino.update(item);
tamino.commit(true);
}catch(Exception e){e.printStackTrace();}
finally{
tamino.endSession();
tamino = null;
}
%>

This is the error i am getting
java.lang.ClassCastException: org.apache.xerces.dom.DeferredTextImpl
at com.docuverse.dom.AbstractContainerNode.appendChild(AbstractContainer
Node.java:294)
at jsp.updateGen_6._jspService(updateGen_6.java:88)
at org.apache.jasper.runtime.HttpJspBase.service(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java)
at org.apache.tomcat.facade.ServletHandler.doService(Unknown Source)
at org.apache.tomcat.core.Handler.invoke(Unknown Source)
at org.apache.tomcat.core.Handler.service(Unknown Source)
at org.apache.tomcat.facade.ServletHandler.service(Unknown Source)
at org.apache.tomcat.core.ContextManager.internalService(Unknown Source)

at org.apache.tomcat.core.ContextManager.service(Unknown Source)
at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(
Unknown Source)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(Unknown Source)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(Unknown
Source)
at java.lang.Thread.run(Thread.java:484)

Is anybody tested for appendChild method

Thanks
Dhiraja

OK the appendChild method you are using is the DOM method and therefore this is a DOM problem !

I see that you are using the old “HTTP Client for Java” which delivers DOM level 1 objects and xerces will probably deliver DOM level 2 objects. I think this is where the exception is coming from. I would suggest using the new “Tamino API for Java” which uses xerces and delivers DOM level 2 objects.