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

In forwards-compatible mode the attribute isn't ignored

XMLWordPrintable

    • b16
    • generic
    • generic
    • Verified

      Name: eaR10174 Date: 10/05/2001


        JAXP XSLT processor complains about unknown attribute of 'xsl:template' element in the following
      stylesheet that should be processed in forwards-compatible mode (See test.java below):
        
               <xsl:stylesheet version='2.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>

      The element 'xsl:template' has the attribute 'a' that is not allowed by XSLT 1.0. This attribute must
      be ignored since the 'xsl:stylesheet' element has the attribute 'version' which value is not equal to
      '1.0'. The XSLT specification (http://www.w3.org/TR/1999/REC-xslt-19991116#forwards) reads:

          "An element enables forwards-compatible mode for itself, its attributes, its descendants and
      their attributes if either it is an xsl:stylesheet element whose version attribute is not equal to
      1.0 ...

      If an element is processed in forwards-compatible mode, then:
         ...

         if the element has an attribute that XSLT 1.0 does not allow the element to have or if the element
      has an optional attribute with a value that the XSLT 1.0 does not allow the attribute to have, then
      the attribute must be ignored."

      This bug is found in the builds jdk1.4.0-beta3-b82, jaxp-1.1.3.

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

      public class test {

          private static String XSL1 = "<xsl:stylesheet version='2.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));
          
                  transformerFactory.newTransformer(source);
          
                  System.out.println("stylesheet processed");
              } 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-11-05

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: