opensubscriber
   Find in this group all groups
 
Unknown more information…

f : fop-user@xml.apache.org 10 March 2005 • 7:02PM -0500

Re: FopServlet
by Jeremias Maerki

REPLY TO AUTHOR
 
REPLY TO GROUP




Does the problem persist if you serialize the SAX events generated by
the Incident with an identity transformer to a file and run the XSL
transformation stand-alone from the command-line?

I don't think it's a problem but did you realize that you have two FOP
processing runs in your testGeneratePDF() method, the first started by
Transformer.transform() and the other by input.run()? Since I can't do
anything with the line numbers in the stack trace, this is something you
have to do.

On 10.03.2005 11:12:07 Ben Gill wrote:
>
>
> -----Original Message-----
> From: Jeremias Maerki [mailto:dev.jeremias@gree...]
> Sent: 10 March 2005 09:37
> To: fop-user@xml....
> 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: fop-user-unsubscribe@xml....
> For additional commands, e-mail: fop-user-help@xml....



Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml....
For additional commands, e-mail: fop-user-help@xml....

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.