File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes XML XSL problem in tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML XSL problem in tomcat" Watch "XML XSL problem in tomcat" New topic

XML XSL problem in tomcat

shawn kennedy
Ranch Hand

Joined: Oct 31, 2002
Posts: 67
I needed help with the following:
I have written a class that taken an xml file and xsl and generates a HTML file as a result.When i run the code on jdk it works fine but when i transfer it to tomcat as a web application and call it from a jsp.It gives me the following error:

; Line#: 1; Column#: 1
javax.xml.transform.TransformerException: Content is not allowed in prolog.
at org.apache.xalan.transformer.TransformerImpl.fatalError(TransformerIm
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImp
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImp
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImp
at com.associa.bacs.xml.RepGen.buildReport(
at BACSImport._0002fBACSImport_0002ffileviewer_0002ejspfileviewer_jsp_6.
at org.apache.jasper.runtime.HttpJspBase.service(
at javax.servlet.http.HttpServlet.service(
at org.apache.jasper.servlet.JspServlet$JspCountedServlet.service(JspSer
at javax.servlet.http.HttpServlet.service(
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspSer
at org.apache.jasper.servlet.JspServlet.serviceJspFile(
at org.apache.jasper.servlet.JspServlet.service(
at javax.servlet.http.HttpServlet.service(
at org.apache.tomcat.core.ServletWrapper.doService(
at org.apache.tomcat.core.Handler.service(
at org.apache.tomcat.core.ServletWrapper.service(
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.
at org.apache.tomcat.core.ContextManager.service(
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnectio
at org.apache.tomcat.service.TcpWorkerThread.runIt(
at org.apache.tomcat.util.ThreadPool$

I am using tomcat 3.2.3 and jdk1.3.1_09.I have to use these two cause the system was developed previously by other people who have written code tht works only on tht version of tomcat.
Also i googled alot for the above error and got alot of solutions but none of them seem to work.There are no non whitespace characters in my xml or xsl prolog.The following is the xml file

<?xml version="1.0" encoding="ISO-8859-1"?>

[ML - snip ]


Both the xml and xsl use same encoding that is iso-8859-1.I also tried using different versions of xalan.jar and other .jars required for xml but to no avail.
Please could someone help me with this.


Edit Comment:
This message was edited to remove some XML information.

- ML
[ May 25, 2005: Message edited by: Madhav Lakkapragada ]
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
Nothing really jumps out at me. But try transforming with other tools like a standalone Xalan-Java or using Felix (don't have the link handy). Maybe they can report a better error.

For some reason I can't explain, I am tempted to say - remove the encoding attribute and give it a shot.

- m............assuming that the XML/XSL is well-formed!

Take a Minute, Donate an Hour, Change a Life
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
Just for fun - try inserting a space after encoding="ISO-8859-1" so it reads

I vaguely recall some problem like that.
shawn kennedy
Ranch Hand

Joined: Oct 31, 2002
Posts: 67
Well i have tried removeing the encoding bits as well as using an XML editor to check its wellformed,validity and the editor also generated the html file using the xml and xsl.So theres no problem on that front.
Does anyone have any other ideas.
Balaji Loganathan
author and deputy

Joined: Jul 13, 2001
Posts: 3150
Could it be a problem that your tomcat uses a older xml parser than your local jdk ??
Just guessing!!
shawn kennedy
Ranch Hand

Joined: Oct 31, 2002
Posts: 67
Hey guys,
Thanks for your help.Ive resolved the problem.It was actually my mistake while testing the java class under jdk i had actually read the xml file into a string reader and used that in the streamsource while using the transform() and that was in the main method.While calling the java class theu the jsp i forgot to perform that step and instead of passing the xml data i was passsing the name of the xml file.Hence it was reading the entire file path instead of xml data so the "Content not allowed in prolog" error.
I agree. Here's the link:
subject: XML XSL problem in tomcat
jQuery in Action, 3rd edition