Dan Barron
2003-11-12 19:43:57 UTC
Hello,
I'm seeing an SAXParseException when I am trying to do a simple xml
transform inside a simple jsp file. I see the exception:
"SAXParseException: Content is not allowed in prolog"
I have checked the prolog in both the xml and xsl files and there are no
extra characters. I can run the transform from the command line with no
errors and it works fine.
Any one have any clues on this problem they would like share?
Included below is my environment, test.xml file, test.xsl file, test.jsp
file, the command line transform, and the tomcat log otput of the exception.
Thanks!
Dan Barron
***@ddive.com
*** environment ***
redhat 7.3
apache 1.3
tomcat 4.1.29
mod_jk 1.2
Java 2 Runtime Environment, Standard Edition (build 1.4.1_02-b06)
*** test.xml file ***
<?xml version="1.0" encoding="UTF-8"?>
<main>
<title>Hello World - xml to xsl test</title>
</main>
*** test.xsl file ***
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<!-- Main Template -->
<xsl:template match="main">
<xsl:value-of select="title"/>
</xsl:template>
</xsl:stylesheet>
*** test.jsp file ***
<%@ page import="java.io.*"%>
<%@ page import="javax.xml.transform.stream.*"%>
<%@ page import="javax.xml.transform.*"%>
<%
out.print("barronfamily.net - /charlineanddan/jsp/test.jsp");
try {
//~~~ get Transformer object & stylesheet to use for transformation ~~~
TransformerFactory tFactory = TransformerFactory.newInstance();
StreamSource xslFile = new
StreamSource("/usr/www/barronfamily.net/charlineanddan/xsl/test.xsl");
Transformer transformer = tFactory.newTransformer( xslFile );
//~~~ setup stream reader and writer ~~~
StringReader stream = new
StringReader("/usr/www/barronfamily.net/charlineanddan/xml/test.xml");
StringWriter writer = new StringWriter( );
//~~~ transform the xml via the stylesheet ~~~
transformer.transform(new StreamSource(stream), new
StreamResult(writer));
out.print(writer.toString());
} catch(Exception e ) {
out.print("<br/><br/>ERROR: XML Tansformation was unsuccessful:\n");
e.printStackTrace();
}
%>
*** Run at Command Line ***
[***@arctictern]# java org.apache.xalan.xslt.Process -in
./xml/test.xml -xsl ./xsl/test.xsl
<?xml version="1.0" encoding="UTF-8"?>
Hello World - xml to xsl test
[***@arctictern]#
*** Catalina/Tomcat Log of javax.xml.transform.TransformerException ***
javax.xml.transform.TransformerException: org.xml.sax.SAXParseException:
Content is not allowed in prolog.
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 org.apache.jsp.test_jsp._jspService(test_jsp.java:64)
...
I'm seeing an SAXParseException when I am trying to do a simple xml
transform inside a simple jsp file. I see the exception:
"SAXParseException: Content is not allowed in prolog"
I have checked the prolog in both the xml and xsl files and there are no
extra characters. I can run the transform from the command line with no
errors and it works fine.
Any one have any clues on this problem they would like share?
Included below is my environment, test.xml file, test.xsl file, test.jsp
file, the command line transform, and the tomcat log otput of the exception.
Thanks!
Dan Barron
***@ddive.com
*** environment ***
redhat 7.3
apache 1.3
tomcat 4.1.29
mod_jk 1.2
Java 2 Runtime Environment, Standard Edition (build 1.4.1_02-b06)
*** test.xml file ***
<?xml version="1.0" encoding="UTF-8"?>
<main>
<title>Hello World - xml to xsl test</title>
</main>
*** test.xsl file ***
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<!-- Main Template -->
<xsl:template match="main">
<xsl:value-of select="title"/>
</xsl:template>
</xsl:stylesheet>
*** test.jsp file ***
<%@ page import="java.io.*"%>
<%@ page import="javax.xml.transform.stream.*"%>
<%@ page import="javax.xml.transform.*"%>
<%
out.print("barronfamily.net - /charlineanddan/jsp/test.jsp");
try {
//~~~ get Transformer object & stylesheet to use for transformation ~~~
TransformerFactory tFactory = TransformerFactory.newInstance();
StreamSource xslFile = new
StreamSource("/usr/www/barronfamily.net/charlineanddan/xsl/test.xsl");
Transformer transformer = tFactory.newTransformer( xslFile );
//~~~ setup stream reader and writer ~~~
StringReader stream = new
StringReader("/usr/www/barronfamily.net/charlineanddan/xml/test.xml");
StringWriter writer = new StringWriter( );
//~~~ transform the xml via the stylesheet ~~~
transformer.transform(new StreamSource(stream), new
StreamResult(writer));
out.print(writer.toString());
} catch(Exception e ) {
out.print("<br/><br/>ERROR: XML Tansformation was unsuccessful:\n");
e.printStackTrace();
}
%>
*** Run at Command Line ***
[***@arctictern]# java org.apache.xalan.xslt.Process -in
./xml/test.xml -xsl ./xsl/test.xsl
<?xml version="1.0" encoding="UTF-8"?>
Hello World - xml to xsl test
[***@arctictern]#
*** Catalina/Tomcat Log of javax.xml.transform.TransformerException ***
javax.xml.transform.TransformerException: org.xml.sax.SAXParseException:
Content is not allowed in prolog.
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 org.apache.jsp.test_jsp._jspService(test_jsp.java:64)
...