Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4409129

Transformer.newTransformer(DOMSource) throws java.lang.NullPointerException

    Details

    • Subcomponent:
    • Resolved In Build:
      1.1fcs
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Description



      Name: eaR10174 Date: 01/29/2001


         JAXP 1.1 method javax.xml.transform.Transformer.newTransformer(DOMSource) throws
      java.lang.NullPointerException (see test.java below).
         
         This bug appears in build jaxp-1.1-b18-26_jan_2001 and affects the new test in TCK JAXP 1.1
        
           api/javax_xml_transform/dom/DOMLocator/index.html#getOriginatingNode()
           
         If "tfactory.setErrorListener(myErrorListener)" is commented the test program executes without
         java.lang.NullPointerException.

      ------------------------------------test.java-----------------------------
      import org.w3c.dom.Document;

      import javax.xml.parsers.DocumentBuilderFactory;
      import javax.xml.parsers.DocumentBuilder;
      import javax.xml.transform.SourceLocator;
      import javax.xml.transform.ErrorListener;
      import javax.xml.transform.TransformerException;
      import javax.xml.transform.TransformerFactory;
      import javax.xml.transform.Transformer;
      import javax.xml.transform.dom.DOMSource;

      import java.io.ByteArrayInputStream;

      public class test {

          public static void main(String argv[]) {
              String xslData = "<?xml version=\"1.0\"?>" +
                               "<xsl:stylesheet" +
                               " xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"" +
                               " version=\"1.0\"" +
                               ">" +
                               " <xsl:template match=\"/\">" +
                               " Hello World! \n" +
                               " <xsl:value-of select=\"string(123, 12345)\"/>" +
                               " </xsl:template>" +
                               "</xsl:stylesheet>";

              try {
                  /* Create a transform factory instance */
                  TransformerFactory tfactory = TransformerFactory.newInstance();
                            
                  MyEL myErrorListener = new MyEL();
                  
                  tfactory.setErrorListener(myErrorListener);
                  
                  /* Create a xml document */
                  DocumentBuilderFactory dBF = DocumentBuilderFactory.newInstance();
                  DocumentBuilder dBuilder = dBF.newDocumentBuilder();
                  byte[] data = xslData.getBytes();
                  ByteArrayInputStream in = new ByteArrayInputStream(data);
                  Document document = dBuilder.parse(in);
                              
                  /* Create a DOMSource instance */
                  DOMSource domSource = new DOMSource(document);

                  /* Try to create a transformer for the stylesheet */
                  Transformer transformer = tfactory.newTransformer(domSource);
                  
              } catch (TransformerException e) {
              } catch (Exception e) {
                  e.printStackTrace();
                  System.exit(1);
              }
              
              System.out.println("okey");
          }
          
          
          /* Definition of class MyEL */
          private static class MyEL implements ErrorListener {
          
              /* implementation of error() method */
              public void error(TransformerException exception)
                     throws TransformerException {
              }
              
              /* implementation of fatalError() method */
              public void fatalError(TransformerException exception)
                     throws TransformerException {
              }
              
              /* implementation of warning() method */
              public void warning(TransformerException exception)
                     throws TransformerException {
              }
          }
      }
      ---------------------------------------------------------------------------
      ---------------------------------------------------------------------------
      JAXP build version: jaxp-1.1-b18-26_jan_2001

      % java -showversion -cp .:jaxp1.1/jaxp.jar:jaxp1.1/crimson.jar test
      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, interpreted mode)

      java.lang.NullPointerException
              at
      org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:632)
              at test.main(test.java:47)
      ---------------------------------------------------------------------------
      JAXP build version: jaxp-1.1ea2-b18-24_jan_2001

      % java -showversion -cp .:jaxp1.1ea2/jaxp.jar:jaxp1.1ea2/crimson.jar test
      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, interpreted mode)

      okey
      ---------------------------------------------------------------------------

      ======================================================================
      costin.manolache@eng 2001-01-29
      costin.manolache@eng 2001-01-29

        Attachments

          Activity

            People

            • Assignee:
              duke J. Duke (Inactive)
              Reporter:
              evgsunw Evg Evg (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: