Uploaded image for project: 'XalanJ2'
  1. XalanJ2
  2. XALANJ-2252

TransformerFactoryImpl.newTemplates is broken according to JAXP 1.3 specs

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Critical
    • Resolution: Unresolved
    • 2.7
    • None
    • transformation
    • None
    • JDK 1.3 and/or 1.4 (use Xalan with endorsed mechanism)

    Description

      According to the JAXP 1.3 specs:
      http://java.sun.com/j2se/1.5.0/docs/api/javax/xml/transform/TransformerFactory.html#newTemplates(javax.xml.transform.Source)
      or according to the JAXP 1.2 specs:
      http://java.sun.com/j2se/1.4.2/docs/api/javax/xml/transform/TransformerFactory.html#newTemplates(javax.xml.transform.Source)
      the newTemplates method never returns a null Templates object.

      I created an XSL file that used a variable that wasn't declared. This causes the org.apache.xpath.operations.Variable class to throw a WrappedRuntimeException that looks like this when written to System.err:
      2005-12-30 11:12:19 StandardContext[/enginframe]: file:/opt/bruno/412b/enginframe/plugins/filemanager/WEBAPP/layout.xsl; Line #22; Column #62; org.apache.xml.utils.WrappedRuntimeException: Could not find variable with the name of img_path

      My code, since I've been using Xalan 2, does the following:
      ...
      Templates templates = fetchTemplates(source);
      if(templates == null) {
      templates = transformerFactory.newTemplates(source);
      // store templates object and use it
      // now I get a NPE !!!
      ...
      }
      ...

      I couldn't understand why using Xalan 2.6.0 the newTemplates method would throw a TransformerConfigurationException while using Xalan 2.7.0 I get a NPE. So I investigated the code and I found out that the DefaultErrorHandler class changed exception handling policy. In Xalan 2.6.0 it would just rethrow the TransformerException, while in Xalan 2.7.0 it prints it to System.err. Now (Xalan 2.7.0) at line 951 in TransformerFactoryImpl, after logging the fatal error that isn't rethrown, a null Templates object is returned. This breaks the specs. In Xalan 2.6.0 this didn't happen because the fatal error is rethrown (so line 821 in TransformerFactoryImpl of Xalan 2.6.0 is never executed!)

      I assigned critical to this bug because I've had crash and loss of data. No priority level exists for breaking specs

      Attachments

        Activity

          People

            Unassigned Unassigned
            aarena Antonio Arena
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: