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

A TransformerConfigurationException is thrown instead of the report about error

    Details

    • Subcomponent:
    • Resolved In Build:
      1.3
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Backports

        Description

        Name: eaR10174 Date: 10/05/2001


          Errors are not reported to System.err when the xsl source with non-fatal errors is processed into a
        Transformer object (see test.java below) and the application does not register an ErrorListener. The
        TransformerConfigurationException is thrown instead of the report. The javadoc description of the
        javax.xml.transform.ErrorListener (jdk1.4.0beta-b82) reads:
          
             "public interface ErrorListener
              ...
              If an application does not register an ErrorListener, errors are reported to System.err."

        This bug is found in the build jdk1.4.0-beta3-b82 and affects a new JCK1.4 test

        api/javax_xml/transform/ErrorListener/index.html#Error[Error002]


        In test.java the xsl source has the error: element 'xsl:template' contains the attribute 'a'. This is
        non-fatal error, the attribute can be ignored.

        ------------------------------------test.java-----------------------------
        import javax.xml.transform.stream.StreamSource;
        import java.io.StringReader;
        import javax.xml.transform.TransformerFactory;
        import java.io.PrintStream;
        import java.io.ByteArrayOutputStream;

        public class test {

            private static String XSL1 = "<xsl:stylesheet version='1.0' "
                                       + "xmlns:xsl='http://www.w3.org/1999/XSL/Transform&#39;>"
                                       + "<xsl:template a='1' match='/'>"
                                       + "<H2><xsl:value-of select='//author'/></h2>"
                                       + "<H1><xsl:value-of select='//title'/></h1>"
                                       + "</xsl:template>"
                                       + "</xsl:stylesheet>";

            public static void main (String[] args) {
                try {
                    /* Create a TransformFactory instance */
                    TransformerFactory transformerFactory = TransformerFactory.newInstance();
            
                    /* Create and init a StreamSource instance */
                    StreamSource source = new StreamSource(new StringReader(XSL1));
            
                    /* Create the "standard" error output stream replacement */
                    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
                    PrintStream err = new PrintStream(byteArrayOutputStream);
            
                    /* Set the new created error output stream */
                    System.setErr(err);
            
                    transformerFactory.newTransformer(source);
            
                    if (byteArrayOutputStream.toString().length() != 0) {
                        System.out.println("OK");
                    } else {
                        System.out.println("No data written to System.err");
                    }
                } catch (Exception e) {
                    System.out.println(e);
                }
            }
        }
        ---------------------------------------------------------------------------
        ---------------------------------------------------------------------------
        % java -showversion test
        java version "1.4.0-beta3"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b82)
        Java HotSpot(TM) Client VM (build 1.4.0-beta3-b82, mixed mode)

        javax.xml.transform.TransformerConfigurationException:
        javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException:
        javax.xml.transform.TransformerException: "a" attribute is not allowed on the xsl:template element!
        ---------------------------------------------------------------------------

        ======================================================================
        ###@###.### 2003-08-13

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  ayadavsunw Arun Yadav (Inactive)
                  Reporter:
                  evgsunw Evg Evg (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: