Loading ...
Sorry, an error occurred while loading the content.

Using FOP_0.14 in a servlet

Expand Messages
  • shrestha@yahoo.com
    My ISP, unfortunately, still has FOP_0.14. I have been using FOP_0.18 to develop my servlet application, and it runs fine, using these command: ... InputSource
    Message 1 of 2 , Jun 22, 2001
    • 0 Attachment
      My ISP, unfortunately, still has FOP_0.14. I have been using
      FOP_0.18 to develop my servlet application, and it runs fine, using
      these command:
      ...
      InputSource source;
      ByteArrayOutputStream foOut;
      ...
      org.apache.fop.apps.Driver driver = new org.apache.fop.apps.Driver
      (source, foOut);
      driver.setRenderer(Driver.RENDER_PDF);
      driver.run();

      To make it work with FOP_0.14, I tried:

      String version = Version.getVersion();
      PrintWriter writer=response.getWriter();
      org.apache.fop.apps.Driver driver = new org.apache.fop.apps.Driver();
      driver.setRenderer("org.apache.fop.render.pdf.PDFRenderer", version);
      driver.setWriter(writer);
      Parser parser=(Parser)Class.forName
      ("com.jclark.xml.sax.Driver").newInstance();
      ParserAdapter parserAdapter=new ParserAdapter(parser);
      driver.buildFOTree(parserAdapter, source);
      driver.format();
      driver.render();

      But I get the error:

      org.apache.fop.apps.FOPException: Unknown namespace prefix: fo

      How can I make my application work with FOP_0.14?

      Thanks
      Roshan
    • shrestha@yahoo.com
      I have found out the answer! XMLReader parser=(XMLReader)Class.forName ( org.apache.xerces.parsers.SAXParser ).newInstance();
      Message 2 of 2 , Jun 22, 2001
      • 0 Attachment
        I have found out the answer!

        XMLReader parser=(XMLReader)Class.forName
        ("org.apache.xerces.parsers.SAXParser").newInstance();
        parser.setFeature("http://xml.org/sax/features/namespace-prefixes",
        true);

        This also means I cannot use James Clarks XP.
        This line is also needed:
        driver.addElementMapping("org.apache.fop.fo.StandardElementMapping");

        Anyway, the output is not at all like the one I get from the latest
        version of FOP. I will have to insist that my ISP update his library!

        Thanks
        Roshan

        --- In XSL-FO@y..., shrestha@y... wrote:
        > My ISP, unfortunately, still has FOP_0.14. I have been using
        > FOP_0.18 to develop my servlet application, and it runs fine, using
        > these command:
        > ...
        > InputSource source;
        > ByteArrayOutputStream foOut;
        > ...
        > org.apache.fop.apps.Driver driver = new
        org.apache.fop.apps.Driver
        > (source, foOut);
        > driver.setRenderer(Driver.RENDER_PDF);
        > driver.run();
        >
        > To make it work with FOP_0.14, I tried:
        >
        > String version = Version.getVersion();
        > PrintWriter writer=response.getWriter();
        > org.apache.fop.apps.Driver driver = new org.apache.fop.apps.Driver
        ();
        > driver.setRenderer("org.apache.fop.render.pdf.PDFRenderer",
        version);
        > driver.setWriter(writer);
        > Parser parser=(Parser)Class.forName
        > ("com.jclark.xml.sax.Driver").newInstance();
        > ParserAdapter parserAdapter=new ParserAdapter(parser);
        > driver.buildFOTree(parserAdapter, source);
        > driver.format();
        > driver.render();
        >
        > But I get the error:
        >
        > org.apache.fop.apps.FOPException: Unknown namespace prefix: fo
        >
        > How can I make my application work with FOP_0.14?
        >
        > Thanks
        > Roshan
      Your message has been successfully submitted and would be delivered to recipients shortly.