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

A default value of the attribute 'method' is always 'xml'

    XMLWordPrintable

    Details

      Description

      Name: eaR10174 Date: 09/24/2001


        Default value of the attribute 'method' is always set to 'xml' in properties list
      returned by methods

          java.util.Properties javax.xml.transform.Templates.getOutputProperties()
          java.util.Properties javax.xml.transform.Transformer.getOutputProperties()

      for sample stylesheet (See test.java below). This stylesheet doesn't contain
      the 'xsl:output' and produces html child for result root element so the value of the
      attribute
      'method' should be 'html' according to the XSLT specification
      (http://www.w3.org/TR/1999/REC-xslt-19991116) :

       " 16. Output
         .....
        
         The default for the method attribute is chosen as follows. If

            - the root node of the result tree has an element child,

            - the expanded-name of the first element child of the root node (i.e. the
              document element) of the result tree has local part html (in any combination
              of upper and lower case) and a null namespace URI, and

            - any text nodes preceding the first element child of the root node of the
              result tree contain only whitespace characters,

         then the default output method is html; otherwise, the default output method is xml."

      This bug is found in the build jdk1.4.0-beta3-b80 and affects a new JCK1.4 test
        
      api/javax_xml/transform/Templates/index.html#GetOutputProperties[GetOutputProperties008]

      ------------------------------------test.java-----------------------------
      import java.io.StringReader;
      import javax.xml.transform.Templates;
      import javax.xml.transform.TransformerFactory;
      import javax.xml.transform.Transformer;
      import javax.xml.transform.stream.StreamSource;

      public class test {
          public static void main(String argv[]) {
      try {
      String xsl = "<?xml version='1.0'?>\n"
                             + "<xsl:stylesheet version='1.0'"
                             + " xmlns:xsl='http://www.w3.org/1999/XSL/Transform&#39;>\n"
                             + " <xsl:template match='/'>\n"
                             + "\n"
                             + "<html>\n"
                             + " <body><xsl:copy-of select='/info/*'/></body>\n"
                             + "</html>\n"
                             + "\n"
                             + " </xsl:template>\n"
                             + "</xsl:stylesheet>\n";
                             
                  System.out.println("xsl-file example:");
                  System.out.println(xsl);

      TransformerFactory tFactory = TransformerFactory.newInstance();
                  
      StreamSource source = new StreamSource(new StringReader(xsl));
      Transformer transformer = tFactory.newTransformer(source);
                  
                  source = new StreamSource(new StringReader(xsl));
                  Templates templates = tFactory.newTemplates(source);
                  
                  System.out.print("Transformer.getOutputProperties() - ");
                  System.out.print("The default value of 'method': ");
                  System.out.println(transformer.getOutputProperties().getProperty("method"));
                  System.out.println("");
                  
                  System.out.print("Templates.getOutputProperties() - ");
                  System.out.print("The default value of 'method': ");
                  System.out.println(templates.getOutputProperties().getProperty("method"));
      } 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-b80)
      Java HotSpot(TM) Client VM (build 1.4.0-beta3-b80, mixed mode)

      xsl-file example:
      <?xml version='1.0'?>
      <xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform&#39;>
        <xsl:template match='/'>

      <html>
        <body><xsl:copy-of select='/info/*'/></body>
      </html>

        </xsl:template>
      </xsl:stylesheet>

      Transformer.getOutputProperties() - The default value of 'method': xml

      Templates.getOutputProperties() - The default value of 'method': xml
      ---------------------------------------------------------------------------

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

        Attachments

          Activity

            People

            Assignee:
            gsharmasunw Gopal Sharma (Inactive)
            Reporter:
            evgsunw Evg Evg (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: