aspose file tools*
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


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML XSL problem in tomcat" Watch "XML XSL problem in tomcat" New topic
Author

XML XSL problem in tomcat

shawn kennedy
Ranch Hand

Joined: Oct 31, 2002
Posts: 67
Hi,
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
pl.java:744)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImp
l.java:720)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImp
l.java:1192)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImp
l.java:1170)
at com.associa.bacs.xml.RepGen.buildReport(RepGen.java:94)
at BACSImport._0002fBACSImport_0002ffileviewer_0002ejspfileviewer_jsp_6.
_jspService(_0002fBACSImport_0002ffileviewer_0002ejspfileviewer_jsp_6.java:78)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspCountedServlet.service(JspSer
vlet.java:130)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspSer
vlet.java:282)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:4
29)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:4
05)
at org.apache.tomcat.core.Handler.service(Handler.java:287)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372
)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.
java:812)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758
)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnectio
n(HttpConnectionHandler.java:213)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:
416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java
:501)
at java.lang.Thread.run(Thread.java:479)





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"?>
<BACSDocument>
<Data>
<MessagingAdvices>
<MessagingHeader

[ML - snip ]


<SignatureMethod></SignatureMethod>
<Signature></Signature>
</BACSDocument>

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.

Thanks

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
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
William Brogden
Author and all-around good cowpoke
Rancher

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

I vaguely recall some problem like that.
Bill


Java Resources at www.wbrogden.com
shawn kennedy
Ranch Hand

Joined: Oct 31, 2002
Posts: 67
Hi,
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
Bartender

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: http://aspose.com/file-tools
 
subject: XML XSL problem in tomcat
 
Similar Threads
Need urgent clariffication
newbie - problems with bean
send file to the client/ jspsmart
Problems passing '%' and '&' as params in jsp:include
Help! Exception at jdom.input.DOMBuilder.build()