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

REGRESSION: xsl:strip-space behaviour is incorrect in Java 5

XMLWordPrintable

      The XSLT parser in 1.5 does not honor xsl:strip-space in the stylesheet. This is a regression from 1.4. Here's the example code and supporting files

      -----------------
      XSLTTest.java
      -----------------
      import javax.xml.transform.*;

      public class XSLTTest {
              public static void main(String[] args) {
                      try {
                              test(args[0], args[1]);
                      } catch (Exception e) {
                              e.printStackTrace();
                      }
              }

              private static void test(final String xsl, final String xml) throws Exception {
                      TransformerFactory tFactory = TransformerFactory.newInstance();
                  Transformer transformer = tFactory.newTransformer(new javax.xml.transform.stream.StreamSource(xsl));
                  transformer.transform (new javax.xml.transform.stream.StreamSource(xml), new javax.xml.transform.stream.StreamResult( System.out ));
              }
      }
      -----------------
      document.xml
      -----------------
      <?xml version="1.0"?>
      <document>

      </document>
      -----------------
      stylesheet.xsl
      -----------------
      <stylesheet version='1.0' xmlns='http://www.w3.org/1999/XSL/Transform&#39;>
        <strip-space elements='*'/>

        <template match='text()'>
      should not be used
        </template>
      </stylesheet>
      ----------------------

      Running the test in 1.4.2 on Linux, the result is

      $ /usr/java/j2sdk1.4.2_10/bin/java XSLTTest stylesheet.xsl document.xml
      <?xml version="1.0" encoding="UTF-8"?>

      With 1.5, I get
       
      $ /usr/java/jdk1.5.0_06/bin/java XSLTTest stylesheet.xsl document.xml
      <?xml version="1.0" encoding="UTF-8"?>
      should not be used
        
      The behaviour is different in 1.5 and is a regression from 1.4

      Release Regression From : 1.4.2
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

      Release Regression From : 1.4.2
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

            spericas Santiago Pericasgeertsen
            ksoshals Kirill Soshalskiy (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: