'Could not compile stylesheet' with XSLTInputHandler(InputSo

Here should go questions about transforming XML with XSLT and FOP.
actini
Posts: 1
Joined: Wed Apr 08, 2009 5:46 am

'Could not compile stylesheet' with XSLTInputHandler(InputSo

Post by actini »

Hi, please help me to resolve this debug, im using FOP to render Report using XML and XSL. But this's a problem when using XSLTInputHandler. I'd tried 2 way

1> With Syntax: XSLTInputHandler(File, File) -> its run ok

public void generateReport(
HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {

XSLTInputHandler input = new XSLTInputHandler(new File("C:\\glossary.xsl"), new File("C:\\glossary.xsl"));
FOPRender render = new FOPRender(response);
render.renderXML(input);

}

2> With Synxtax: XSLTInputHandler(InputSource, InputSource) -> Error: 'Could not compile stylesheet'

Details:

[Fatal Error] :1:1: Premature end of file.
ERROR: 'Premature end of file.'
FATAL ERROR: 'Could not compile stylesheet'
org.apache.fop.apps.FOPException: Could not compile stylesheet
at org.apache.fop.apps.TraxInputHandler.initTransformer(TraxInputHandler.java:108)
at org.apache.fop.apps.TraxInputHandler.<init>(TraxInputHandler.java:100)
at org.apache.fop.apps.XSLTInputHandler.<init>(XSLTInputHandler.java:81)
at com.n2n.report.bean.test.generateReport(test.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.n2n.report.servlet.ReportSerlvet.doPost(ReportSerlvet.java:75)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:619)


My code is very simple for test:

public void generateReport(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {

InputStream inXSL = new FileInputStream("C:/glossary.xsl");
DataInputStream dis;
dis = new DataInputStream(inXSL);
while(dis.available()!=0){
System.out.println(dis.readLine());
}

InputStream inXML = new FileInputStream("C:/glossary.xml");
dis = new DataInputStream(inXML);
while(dis.available()!=0){
System.out.println(dis.readLine());
}

FOPRender render = new FOPRender(response);
XSLTInputHandler input = null;
try {
input = new XSLTInputHandler(new InputSource(inXML), new InputSource(inXSL));
} catch (FOPException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
render.renderXML(input);
}

When im using :

DataInputStream dis;
dis = new DataInputStream(inXSL);
while(dis.available()!=0){
System.out.println(dis.readLine());
}

The Content of 2 files is displayed successfully
Thanks very much
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: 'Could not compile stylesheet' with XSLTInputHandler(InputSo

Post by sorin_ristache »

Hello,

It seems you want to transform an XML file to PDF using a servlet. I think you can get useful answers on other forums that are specialized in these issues (servlets, running an XSLT stylesheet in Java code). This forum is about XSLT and FOP transformations in XML tools, mainly in Oxygen.


Regards,
Sorin
Post Reply