Uploaded image for project: 'FOP'
  1. FOP
  2. FOP-2362

[PATCH] Using Saxon to intermediate format throws NullPointerException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.1
    • None
    • unqualified
    • None
    • Apple OSX 10.9.2 / Java version 1.7.0_11

    Description

      When rendering an XSL-FO file that contains an AFP-Extension to the intermediate format while using Saxon as XSLT transformer, a NullPointerException is thrown.

      Steps to reproduce:
      1. Download and unpack the FOP 1.1 binary release.
      2. Change into the root directory "fop-1.1" of the release
      3. Download Saxon HE from http://repo1.maven.org/maven2/net/sf/saxon/Saxon-HE/9.4/Saxon-HE-9.4.jar and copy the file to the lib directory of the FOP 1.1 release
      4. Edit the file fop that is located in the root directory of the release and add the following JVM parameter to the java_exec_args:
      -Djavax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactoryImpl
      The line should now look like:
      java_exec_args="-Djava.awt.headless=true -Djavax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactoryImpl"
      5. Download the attached files test.fo and simple.xsl and run the following fop command:
      fop -fo test.fo -out application/X-fop-intermediate-format test.if.xml

      Actual Results:
      Application throws NullPointerException:
      java.lang.NullPointerException
      at net.sf.saxon.event.ReceivingContentHandler.getNodeName(ReceivingContentHandler.java:391)
      at net.sf.saxon.event.ReceivingContentHandler.startElement(ReceivingContentHandler.java:316)
      at org.apache.fop.util.DelegatingContentHandler.startElement(DelegatingContentHandler.java:185)
      at org.apache.fop.render.afp.extensions.AFPPageSetup.toSAX(AFPPageSetup.java:125)
      at org.apache.fop.render.intermediate.IFSerializer.handleExtensionObject(IFSerializer.java:680)

      Expected Results:
      Application should render IF from FO

      Additional Information:
      In the toSAX method of the class org.apache.fop.render.afp.extensions.AFPPageSetup the method addAttribute of the class org.xml.sax.helpers.AttributesImpl is called with null as first argument. Due to the APIDOC of the class org.xml.sax.helpers.AttributesImpl the first argument must either be the namespace or an empty string, but not null:

      uri - The Namespace URI, or the empty string if none is available or Namespace processing is not being performed.

      When changing the parameter value to an empty string, no NullPointerException is thrown anymore. The same problem exists in other classes in the package org.apache.fop.render.afp.extensions, so I added a diff file for the complete package (extensions.diff).

      The exception is not thrown when using Xalan as XSL transformer.

      Attachments

        1. extensions.diff
          5 kB
          Hauke Haastert
        2. test.fo
          0.8 kB
          Hauke Haastert
        3. simple.xsl
          1 kB
          Hauke Haastert

        Activity

          People

            ssteiner Simon Steiner
            hauke@convertic.ch Hauke Haastert
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: