Hi!
I've tried your code earlier but I can't seems to make it work. An
exception occurs on the docOut.importNode() method.
Transformer transformer = TransformerFactory.newInstance().newTransformer();
Document docOut =
DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
NodeList nodeList = root.getElementsByTagName("dossier"); // m_doc was also
created using DocumentBuilder()
if (nodeList.getLength() >= 1)
{
docOut.importNode(nodeList.item(0),true); // !!!!!!!!!!!!! The exception
occured here.
}
Exception in thread "main" java.lang.IllegalArgumentException: Node is not a org
.apache.crimson.tree implementation.
at org.apache.crimson.tree.TreeWalker.<init>(TreeWalker.java:113)
at org.apache.crimson.tree.XmlDocument.importNode(XmlDocument.java, Compiled
Code)
at XMLTest.writeFile(XMLTest.java:218)
at XMLTest.<init>(XMLTest.java:66)
at XMLTest.main(XMLTest.java:288)
Thanks...
Steeve...
"Bardman, Jody" <[EMAIL PROTECTED]> on 08/08/2001 08:24:33 AM
Please respond to [EMAIL PROTECTED]
To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
cc: (bcc: Steeve Gilbert/G_STGEORGES/CANAM_MANAC)
Subject: RE: Working with Xerces
This is really weird...
I compiled the code and I can step into the code in the JBuilder debugger.
Everything looks fine.
But, when I try to run it from the browser I get the error listed below:
I took out the call to the code listed in Steeve's previous e-mail. No
difference.
I took out all of the code except for the instantiation of the class from
my JSP file and it still blows up.
The error only disappears when I comment out the code!!!
In other words, as long as the code is in my Java file, if it is called or
not it still blows up.
I thought about the ClassPath for the javax jars but it seems OK.
Any ideas?
Jody
500 Internal Server Error
Exception thrown processing JSP page.
java.lang.NoClassDefFoundError: javax/xml/transform/TransformerException
������� at java.lang.Class.forName0(Native Method)
������� at java.lang.Class.forName(Class.java:120)
������� at jrun__Soap12ejspa.class$(jrun__Soap12ejspa.java)
������� at jrun__Soap12ejspa._jspService(jrun__Soap12ejspa.java:44)
������� at allaire.jrun.jsp.HttpJSPServlet.service
(../jsp/HttpJSPServlet.java:39)
������� at allaire.jrun.jsp.JSPServlet.service(../jsp/JSPServlet.java:228)
������� at allaire.jrun.jsp.JSPServlet.service(../jsp/JSPServlet.java:196)
������� at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1416)
������� at allaire.jrun.session.JRunSessionService.service
(../session/JRunSessionService.java:1082)
������� at allaire.jrun.servlet.JRunSE.runServlet
(../servlet/JRunSE.java:1270)
������� at allaire.jrun.servlet.JRunRequestDispatcher.forward
(../servlet/JRunRequestDispatcher.java:89)
������� at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1552)
������� at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1542)
������� at allaire.jrun.servlet.JvmContext.dispatch
(../servlet/JvmContext.java:364)
������� at allaire.jrun.http.WebEndpoint.run(../http/WebEndpoint.java:115)
������� at allaire.jrun.ThreadPool.run(../ThreadPool.java:272)
������� at allaire.jrun.WorkerThread.run(../WorkerThread.java:75)
-----Original Message-----
From: Steeve Gilbert [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 02, 2001 4:44 PM
To: [EMAIL PROTECTED]
Subject: RE: Working with Xerces
You can get the full explanation here...
http://java.sun.com/xml/jaxp-1.1/docs/tutorial/xslt/2_write.html
They output it to the console but if you wanna get it into a string look at
this...
����� Transformer transformer = (TransformerFactory.newInstance
()).newTransformer();
����� StringWriter strwriter = new StringWriter();
����� DOMSource source = new DOMSource(document);
����� StreamResult result = new StreamResult(strwriter);
����� transformer.transform(source, result);
����� XMLSTR = strwriter.toString();� //Here you get the string
Good luck!
Steeve...
"Gus Delgado" <[EMAIL PROTECTED]> on 02/08/2001 03:42:15 PM
Please respond to [EMAIL PROTECTED]
To:�� <[EMAIL PROTECTED]>
cc:��� (bcc: Steeve Gilbert/G_STGEORGES/CANAM_MANAC)
Subject:� RE: Working with Xerces
Document doc = parser.getDocument();
Element� e� =� null;
NodeList nl =�doc.getElementsByTagName("tagName");
e = (Element)� nl.item(0);
e.normalize();
NodeList nl =� e.getChildNodes();
Node textNode = nl.item(0);
String�value =�textNode.getNodeValue()�;
-----Original Message-----
From: Bardman, Jody� [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 02, 2001 2:15� PM
To: [EMAIL PROTECTED]
Subject: Working with� Xerces
My SOAP client can build a simple request and send� it to the SOAP server
and then receive the response.
I can parse the data.
Now comes the next step:
1). Send a request
2).� Receive the XML response.
3). Save the� XML.
4). Parse some of the XML� response.
5). Add new XML data to what was� saved for a new request.
6). Send the new� request.
So basically I want to get the response, add to it,� and send it out again.
Here is how I was parsing the simple� response:
� DOMParser parser = new� DOMParser();� //Create a parser
�� parser.parse(new InputSource(new StringReader(XMLPref)));� //Create the
DOM
� Document doc =� parser.getDocument();
I was hoping to add data by way of the doc/node� classes.
How do I get the full XML out of the Document� class so I can use it for a
new request?
Thanks
Jody