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

Xalan regression: ${{something.{$else}}} not recognized as an attribute value te

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P2
    • Resolution: Fixed
    • Affects Version/s: 5.0
    • Fix Version/s: 1.3.0
    • Component/s: xml
    • Labels:

      Backports

        Description

        JDK 1.5.0 b51 has a regression in Xalan. (And I think b50 as well; not sure when the regression was introduced.) Most easily seen from the following test case:

        ---%<--- TestXalan.java
        import javax.xml.transform.Transformer;
        import javax.xml.transform.TransformerFactory;
        import javax.xml.transform.stream.StreamResult;
        import javax.xml.transform.stream.StreamSource;
        public class TestXalan {
            public static void main(String[] args) throws Exception {
                System.err.println("Java version: " + System.getProperty("java.version"));
                TransformerFactory f = TransformerFactory.newInstance();
                String xsl = TestXalan.class.getResource("test.xsl").toExternalForm();
                System.err.println("XSL=" + xsl);
                Transformer t = f.newTransformer(new StreamSource(xsl));
                String xml = TestXalan.class.getResource("test.xml").toExternalForm();
                System.err.println("XML=" + xml);
                t.transform(new StreamSource(xml), new StreamResult(System.out));
                System.err.println("Done.");
            }
        }
        ---%<--- test.xml
        <?xml version="1.0" encoding="UTF-8"?>
        <whatever/>
        ---%<--- test.xsl
        <?xml version="1.0" encoding="UTF-8"?>
        <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
            <xsl:output method="xml" indent="yes" encoding="UTF-8"/>
            <xsl:template match="/">
                <xsl:variable name="foo" select="'fooval'"/>
                <foo fooval="${{whatever.{$foo}}}"/>
                <!--
                <foo>
                    <xsl:attribute name="fooval">${whatever.<xsl:value-of select="$foo"/>}</xsl:attribute>
                </foo>
                -->
            </xsl:template>
        </xsl:stylesheet>
        ---%<---

        Test machine:

        Linux localhost 2.4.20-20.9 #1 Mon Aug 18 11:45:58 EDT 2003 i686 i686 i386 GNU/Linux
        LSB_VERSION="1.3"
        Red Hat Linux release 9 (Shrike)
        glibc-2.3.2-27.9.7

        Output under JDK 1.4.2_04 vs. JDK 1.5.0 b51:

        $ /space/jdk1.4.2_04/bin/java -showversion -classpath ~/testxalan/build/classes TestXalan
        java version "1.4.2_04"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b02)
        Java HotSpot(TM) Client VM (build 1.4.2_04-b02, mixed mode)

        Java version: 1.4.2_04
        XSL=file:/home/jglick/testxalan/build/classes/test.xsl
        XML=file:/home/jglick/testxalan/build/classes/test.xml
        <?xml version="1.0" encoding="UTF-8"?>
        <foo fooval="${whatever.fooval}"/>
        Done.

        $ /space/jdk1.5.0-b51/bin/java -showversion -classpath ~/testxalan/build/classes TestXalan
        java version "1.5.0-beta2"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b51)
        Java HotSpot(TM) Client VM (build 1.5.0-beta2-b51, mixed mode, sharing)

        Java version: 1.5.0-beta2
        XSL=file:/home/jglick/testxalan/build/classes/test.xsl
        ERROR: 'Error parsing XPath expression 'null'.'
        FATAL ERROR: 'Could not compile stylesheet'
        Exception in thread "main" javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet
        at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:824)
        at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:619)
        at TestXalan.main(TestXalan.java:11)

        This shows a regression in Xalan, probably due to use of XSLTC (guessing).

        As far as I know the stylesheet is legal:

        http://www.w3.org/TR/xslt#dt-attribute-value-template

        says that

        "When an attribute value template is instantiated, a double left or right curly brace outside an expression will be replaced by a single curly brace. It is an error if a right curly brace occurs in an attribute value template outside an expression without being followed by a second right curly brace. A right curly brace inside a Literal in an expression is not recognized as terminating the expression."

        and

        "Curly braces are not recognized recursively inside expressions."

        but as far as I can see the example usage

        <foo fooval="${{whatever.{$foo}}}"/>

        does not fall afoul of any of these restrictions. (Even if it did, the poor error reporting would be sufficient cause for a bug in and of itself.)

        Reported as a P1 bug against a development version of the NetBeans IDE, which uses XSLT to produce Ant scripts using this sort of syntax. Bug materialized (when running under JDK 1.5) after removing Xalan 2.6.0 from the build and relying on the JDK's default XSLT processor instead:

        http://www.netbeans.org/issues/show_bug.cgi?id=43624
        ###@###.### 2004-05-20
        ###@###.### 2004-05-25

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                ayadavsunw Arun Yadav (Inactive)
                Reporter:
                jglick Jesse Glick (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: