-----Original Message----- From: Jeremias Maerki [mailto:[EMAIL PROTECTED] Sent: 10 March 2005 09:37 To: [EMAIL PROTECTED] Subject: Re: FopServlet
On 10.03.2005 08:49:26 Ben Gill wrote: > Hi, > > ok I tried it again and get the same exception!! > > Here is my code (well I have given you the equiv with project team!): <snip/> Hmm, you are still using the InputHandler approach which I personally don't consider ideal. I'd integrate the renderXML() method into the main execute method and use the pattern from ExampleObj2PDF 1:1. But I can't tell if your problem has something to do with that. Probably not. Ok, I tried this and still get the same error... I have created a Junit test for this and here is my code, based upon the ExampleObj2PDF example: public void testGeneratePDF() throws Exception { try { Incident incident = incidentsDAO.loadIncident(new Long(121)); File baseDir = new File("."); File outDir = new File(baseDir, "out"); outDir.mkdirs(); File xslFile = new File(baseDir, "../source/src/com/ocado/tracker/incidents/fop/incident2FO.xsl"); Driver driver = new Driver(); Logger logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO); driver.setLogger(logger); MessageHandler.setScreenLogger(logger); driver.setRenderer(Driver.RENDER_PDF); ByteArrayOutputStream out = new ByteArrayOutputStream(); try { driver.setOutputStream(out); //Setup XSLT TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(new StreamSource(xslFile)); //Setup input for XSLT transformation Source src = incident.getSource(); //Resulting SAX events (the generated FO) must be piped through to FOP Result res = new SAXResult(driver.getContentHandler()); //Start XSLT transformation and FOP processing transformer.transform(src, res); } finally { if (out!=null) { out.close(); } } SAXSource xmlSource = new SAXSource(new IncidentsXMLReader(), new IncidentsInputSource(incident)); SAXSource xslSource = new SAXSource( new InputSource(new FileInputStream(xslFile))); TraxInputHandler input = new TraxInputHandler(xmlSource.getInputSource(), xslSource.getInputSource()); input.run(driver); byte[] content = out.toByteArray(); log.debug("Got content [" + content + "]"); } catch (Exception e) { log.error("Error [" + e.getMessage() + "]", e); } } obviously,my Incident is your ProjectTeam!!! > > and here is the stack trace: > > 2005-03-10 07:40:21 StandardContext[/tracker]: Mapped to servlet 'fop' with > servlet path '/fop' and path info 'null' and update=true > 2005-03-10 07:40:23 StandardWrapperValve[fop]: Servlet.service() for servlet > fop threw exception > javax.servlet.ServletException: java.net.MalformedURLException > at > com.ocado.tracker.common.FopServlet.renderXML(FopServlet.java:150) > at com.ocado.tracker.common.FopServlet.execute(FopServlet.java:116) Ok, this doesn't say much other than there's an URL somewhere that's making problems. Yes, and it could be the way this: "../source/src/com/ocado/tracker/incidents/fop/incident2FO.xsl"); (but the it finds the xsl file and says it exists and this is the string I use for my working version...) or in the XSL: <xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo"> and/or <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> As you noted, the error is coming from the DTD: Caused by: java.net.MalformedURLException at java.net.URL.<init>(URL.java:571) at java.net.URL.<init>(URL.java:434) at java.net.URL.<init>(URL.java:383) at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source) at org.apache.xerces.impl.XMLEntityManager.startDocumentEntity(Unknown Source) at org.apache.xerces.impl.XMLDocumentScannerImpl.setInputSource(Unknown Source) at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source) at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at org.apache.xml.dtm.ref.DTMManagerDefault.getDTM(DTMManagerDefault.java:495) at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java: 658) and there is no DTD reference in the XML I pass in, so it looks like it is having a problem with one of the two URL's in the XSL stylesheet... I always wonder why these core Java classes dont throw out what the URL it thinks is malformed!! Regards This message has been checked for all known viruses by the MessageLabs Virus Control Centre. ********************************************************************* Notice: This email is confidential and may contain copyright material of Ocado Limited (the "Company"). Opinions and views expressed in this message may not necessarily reflect the opinions and views of the Company. If you are not the intended recipient, please notify us immediately and delete all copies of this message. Please note that it is your responsibility to scan this message for viruses. Company reg. no. 3875000. Ocado Limited Titan Court 3 Bishops Square Hatfield Business Park Hatfield Herts AL10 9NE ********************************************************************* --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]