• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

'Could not compile stylesheet' with XSLTInputHandler(InputSource, InputSource)

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

Please help me and Reply to me as soon as you can. Thanks very much
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

[Fatal Error] :1:1: Premature end of file.



I would bet that you failed to check for errors in the creation of those InputSource objects.

Bill
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First you read the contents of the InputStream (in a rather peculiar way) until it's finished. Then you tell your transformer to read from that InputStream. Naturally there isn't anything left in the InputStream and you get that error message.
 
Pham Duy Hung
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank, i've resolved this problem. my fop version is 0.25. i tried using fop 0.95, it run ok
reply
    Bookmark Topic Watch Topic
  • New Topic