File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes Xalan - TransformerException. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Xalan - TransformerException." Watch "Xalan - TransformerException." New topic
Author

Xalan - TransformerException.

Ritu Kama
Ranch Hand

Joined: Sep 10, 2001
Posts: 72
Hi,
I am transforming XML in a servlet. The logic is simple. Client sends the XML in content of HTTP Post. The XML contains the name of Stylesheet with <xml-stylesheet> Processing Instruction.
However, when I try to do the transformation I get the TransformException
It seems to me that if I try to use xmlSource then it looses it's contents. So if I use it next time, I get some form of exception -
The exception looks as follows:
The root element is required in a well-formed document.javax.xml.transform.TransformerException: The root element is req
uired in a well-formed document.
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:686)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1088)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1066)
at TransformXML.doPost(TransformXML.java:34)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.servlet.engine.webapp.StrictServletInstance.doService(ServletManager.java:827)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet._service(StrictLifecycleServlet.java:167)
at com.ibm.servlet.engine.webapp.IdleServletState.service(StrictLifecycleServlet.java:297)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet.service(StrictLifecycleServlet.java:110)
at com.ibm.servlet.engine.webapp.ServletInstance.service(ServletManager.java:472)
at com.ibm.servlet.engine.webapp.ValidServletReferenceState.dispatch(ServletManager.java:1012)
at com.ibm.servlet.engine.webapp.ServletInstanceReference.dispatch(ServletManager.java:913)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:523)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:282)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:112)
at com.ibm.servlet.engine.srt.WebAppInvoker.doForward(WebAppInvoker.java:91)
at com.ibm.servlet.engine.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:184)
at com.ibm.servlet.engine.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:67)
at com.ibm.servlet.engine.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:122)
at com.ibm.servlet.engine.oselistener.OSEListenerDispatcher.service(OSEListener.java:315)
at com.ibm.servlet.engine.http11.HttpConnection.handleRequest(HttpConnection.java:60)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:323)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:252)
at com.ibm.ws.util.CachedThread.run(ThreadPool.java:122)
-----------------------------------
The source code is as follows:
Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1168
The root element is required in a well-formed document.javax.xml.transform.TransformerException: The root element is req
uired in a well-formed document.

It seems that you deal with a document which is not well-formed.
Cheers,
Dan


William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
Ritu Kama
Ranch Hand

Joined: Sep 10, 2001
Posts: 72
Well, the xmlSource document is somehow getting lost and I get this exception.
It will be really helpful if you can tell me why that is happening. Seems to me that when I use xmlSource the first time for getAssociatedStylesheet(), the xmlSource content gets lost (like an EOF of some kind)
 
jQuery in Action, 2nd edition
 
subject: Xalan - TransformerException.
 
Similar Threads
Transformation works at the command line but fails in my web application.
connection to database
XML -2- HTML Transformer Factory Configuration Error
Urgent - XSL Transformations using Websphere 4.0
very urgent...websphere 4.0