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

log apache fop error

Expand Messages
  • markivs2003
    Hello, How can I log apache fop error messages ? I am using saxon for xsl transformation and apache fop for PDF generation. I am able to log saxon error
    Message 1 of 5 , Dec 5, 2003
    • 0 Attachment
      Hello,
      How can I log apache fop error messages ?
      I am using saxon for xsl transformation and apache fop for PDF
      generation. I am able to log saxon error messages using their API.
      Basically I wrote my own version of the ErrorListener class.

      Can someone tell me how to log the fop error messages ? Since saxon
      has access to fop's API, one would imagine that saxon error handler
      would also handle
      fop errors right ?

      Thanks for the help.
    • J.Pietschmann
      ... Actually it s the other way around. For logging FOP erors you have to implement the avalon logger interface. There are a few implementations for various
      Message 2 of 5 , Dec 6, 2003
      • 0 Attachment
        markivs2003 wrote:
        > How can I log apache fop error messages ?
        > I am using saxon for xsl transformation and apache fop for PDF
        > generation. I am able to log saxon error messages using their API.
        > Basically I wrote my own version of the ErrorListener class.
        >
        > Can someone tell me how to log the fop error messages ? Since saxon
        > has access to fop's API, one would imagine that saxon error handler
        > would also handle fop errors right ?

        Actually it's the other way around.

        For logging FOP erors you have to implement the avalon logger
        interface. There are a few implementations for various log
        kits in the avalon toolkit. You have to set this as the
        logger and the FOP message handler.
        See
        http://xml.apache.org/fop/embedding.html#basic-logging

        J.Pietschmann
      • markivs2003
        Thanks a lot for your response. I implemented the logger interface. But I am not sure how to call that from the transformer. I am fairly new to Java, so bare
        Message 3 of 5 , Dec 8, 2003
        • 0 Attachment
          Thanks a lot for your response.

          I implemented the logger interface. But I am not sure how to call
          that from the transformer. I am fairly new to Java, so bare with my
          simple questions. Please take a look at the code below.

          I implemented logger interface and called it TransformerLog.java
          In my other class where I do the transformation, this is what I
          did ...

          TransformerLog tl = new TransformerLog();

          //Construct driver
          Driver driver = new Driver();
          driver.setLogger(tl);
          driver.setOutputStream(oStream);

          Result res = new SAXResult(driver.getContentHandler());

          DOMSource domsrc = new DOMSource(source);
          domsrc.setSystemId(r.getRequestURI());
          transformer.transform(domsrc, res);

          Can you please tell me what I am doing wrong or direct me in the
          right direction ?
          Also, in your response, you had mentioned about Message handler.
          I am not sure what I should do with that.

          Not sure if this will help, but this is the exception I get...
          java.lang.NullPointerException
          at org.apache.fop.apps.StreamRenderer.startRenderer(Unknown Source)
          at org.apache.fop.fo.FOTreeBuilder.startDocument(Unknown Source)
          at com.icl.saxon.output.ContentHandlerProxy.startDocument
          (ContentHandlerProxy.java:81)
          at com.icl.saxon.output.ProxyEmitter.startDocument
          (ProxyEmitter.java:61)
          at com.icl.saxon.output.Outputter.open(Outputter.java:58)
          at com.icl.saxon.output.GeneralOutputter.setOutputDestination
          (GeneralOutputter.java:70)
          at com.icl.saxon.Controller.changeOutputDestination
          (Controller.java:405)
          at com.icl.saxon.Controller.transformDocument(Controller.java:1069)
          at com.icl.saxon.Controller.transform(Controller.java:946)


          --- In XSL-FO@yahoogroups.com, "J.Pietschmann" <j3322ptm@y...> wrote:
          > markivs2003 wrote:
          > > How can I log apache fop error messages ?
          > > I am using saxon for xsl transformation and apache fop for PDF
          > > generation. I am able to log saxon error messages using their
          API.
          > > Basically I wrote my own version of the ErrorListener class.
          > >
          > > Can someone tell me how to log the fop error messages ? Since
          saxon
          > > has access to fop's API, one would imagine that saxon error
          handler
          > > would also handle fop errors right ?
          >
          > Actually it's the other way around.
          >
          > For logging FOP erors you have to implement the avalon logger
          > interface. There are a few implementations for various log
          > kits in the avalon toolkit. You have to set this as the
          > logger and the FOP message handler.
          > See
          > http://xml.apache.org/fop/embedding.html#basic-logging
          >
          > J.Pietschmann
        • Chris Bowditch
          markivs2003 wrote: ... You need to add this static call in your code above: MessageHandler.setScreenLogger(tl); Chris
          Message 4 of 5 , Dec 8, 2003
          • 0 Attachment
            markivs2003 wrote:

            <snip/>

            > TransformerLog tl = new TransformerLog();
            >
            > //Construct driver
            > Driver driver = new Driver();
            > driver.setLogger(tl);
            > driver.setOutputStream(oStream);
            >
            > Result res = new SAXResult(driver.getContentHandler());
            >
            > DOMSource domsrc = new DOMSource(source);
            > domsrc.setSystemId(r.getRequestURI());
            > transformer.transform(domsrc, res);
            >
            > Can you please tell me what I am doing wrong or direct me in the
            > right direction ?
            > Also, in your response, you had mentioned about Message handler.
            > I am not sure what I should do with that.

            You need to add this static call in your code above:

            MessageHandler.setScreenLogger(tl);

            <snip/>

            Chris
          • J.Pietschmann
            ... You probably have to include something like MessageHandler.setScreenLogger(tl); otherwise some ( or a lot) messages may go elsewhere. ... You probably
            Message 5 of 5 , Dec 8, 2003
            • 0 Attachment
              markivs2003 wrote:
              > Also, in your response, you had mentioned about Message handler.
              > I am not sure what I should do with that.
              >
              You probably have to include something like
              MessageHandler.setScreenLogger(tl);
              otherwise some ( or a lot) messages may go elsewhere.

              > Not sure if this will help, but this is the exception I get...
              > java.lang.NullPointerException
              > at org.apache.fop.apps.StreamRenderer.startRenderer(Unknown Source)

              You probably didn't set up a renderer. Add
              driver.setRenderer(Driver.RENDER_PDF);
              after instantiating the driver.

              J.Pietschmann
            Your message has been successfully submitted and would be delivered to recipients shortly.