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

Transformer.setOutputProperties() doesn't throw IllegalArgumentException

    XMLWordPrintable

    Details

      Description

      Name: eaR10174 Date: 10/10/2001


        Method javax.xml.transform.Transformer.setOutputProperties(Properties oformat) does not
      throw the IllegalArgumentException in case when the argument key should not be recognized
      (See test1.java below) and in case when the key name is not namespace qualified (See
      test2.java).
        
        The javadoc description (build jdk1.4.0beta-b82) of this method reads:
        
          "public abstract void setOutputProperties(Properties oformat)
                                        throws IllegalArgumentException
             ...
           Throws:
               IllegalArgumentException - if any of the argument keys are not recognized and are
               not namespace qualified."

        This bug is found in the builds jdk1.4.0-beta3-b82, jaxp-1.1.3 and affects new JCK1.4
      tests

      api/javax_xml/transform/Transformer/index.html#GetSetOProperties[GetSetOProperties011]
      api/javax_xml/transform/Transformer/index.html#GetSetOProperties[GetSetOProperties012]

      ------------------------------------test1.java-----------------------------
      import javax.xml.transform.stream.StreamSource;
      import java.io.StringReader;
      import javax.xml.transform.TransformerFactory;
      import javax.xml.transform.Transformer;
      import java.util.Properties;
      import javax.xml.transform.OutputKeys;

      public class test1 {

          public static void main (String[] args) {
              try {
                  String xslData = "<?xml version='1.0'?>"
                                 + "<xsl:stylesheet"
                                 + " version='1.0'"
                                 + " xmlns:xsl='http://www.w3.org/1999/XSL/Transform&#39;"
                                 + ">\n"
                                 + " <xsl:template match='/'>\n"
                                 + " Hello World! \n"
                                 + " </xsl:template>\n"
                                 + "</xsl:stylesheet>";
                           
                  /* Create a transform factory instance */
                  TransformerFactory tfactory = TransformerFactory.newInstance();

                  /* Create a StreamSource instance */
                  StreamSource streamSource = new StreamSource(new StringReader(xslData));

                  Transformer transformer = tfactory.newTransformer(streamSource);
                  
                  Properties properties = new Properties();
                  properties.setProperty("xyz", "123");
                  transformer.setOutputProperties(properties);
                  
                  System.out.println("IllegalArgumentException not thrown");
              } catch (IllegalArgumentException e) {
                  System.out.println("OK");
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      }
      ---------------------------------------------------------------------------
      ------------------------------------test2.java-----------------------------
      import javax.xml.transform.stream.StreamSource;
      import java.io.StringReader;
      import javax.xml.transform.TransformerFactory;
      import javax.xml.transform.Transformer;
      import java.util.Properties;
      import javax.xml.transform.OutputKeys;

      public class test2 {

          public static void main (String[] args) {
              try {
                  String xslData = "<?xml version='1.0'?>"
                                 + "<xsl:stylesheet"
                                 + " version='1.0'"
                                 + " xmlns:xsl='http://www.w3.org/1999/XSL/Transform&#39;"
                                 + " xmlns:test='http://xxx.xx.xx/2001/XSL/Test&#39;"
                                 + ">\n"
                                 + " <xsl:output test:type='java'/>"
                                 + " <xsl:template match='/'>\n"
                                 + " Hello World! \n"
                                 + " </xsl:template>\n"
                                 + "</xsl:stylesheet>";
                           
                  /* Create a transform factory instance */
                  TransformerFactory tfactory = TransformerFactory.newInstance();

                  /* Create a StreamSource instance */
                  StreamSource streamSource = new StreamSource(new StringReader(xslData));

                  Transformer transformer = tfactory.newTransformer(streamSource);
                  
                  Properties properties = new Properties();
                  properties.setProperty("type", "c++");
                  transformer.setOutputProperties(properties);
                  
                  System.out.println("IllegalArgumentException not thrown");
              } catch (IllegalArgumentException e) {
                  System.out.println("OK");
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      }
      ---------------------------------------------------------------------------
      % java -showversion test1
      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)

      IllegalArgumentException not thrown

      % java -showversion test2
      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)

      IllegalArgumentException not thrown
      ---------------------------------------------------------------------------

      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            vkorcl Venugopal K (Inactive)
            Reporter:
            evgsunw Evg Evg (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: