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

XPath: expression with undefined function is not compiled

    Details

    • Subcomponent:
    • Resolved In Build:
      1.3
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        Name: eaR10174 Date: 12/25/2003


        The method

             javax.xml.xpath.XPath.compile()

        does not compile a valid expression containing an user-defined function that can not
        be resolved during compilation. According to the javadoc functions are resolved during
        evaluation of compiled expressions.

        The bug affects new JCK1.5 tests:

           api/javax_xml/xpath/XPathExpression/index.html#Evaluate[Evaluate029]
           api/javax_xml/xpath/XPathExpression/index.html#Evaluate[Evaluate031]

        The following test fails running on JDK 1.5.0-beta-b32.
        See below the test source and the execution log:
        ------------------------------------Test.java-----------------------------
        import javax.xml.xpath.XPath;
        import javax.xml.xpath.XPathFactory;
        import javax.xml.xpath.XPathConstants;

        public class Test {
             public static void main (String[] args) {
                 Test test = new Test();
                 test.case01();
             }

             public void case01() {
                 System.out.print("case01 - ");
                 try {
                     XPathFactory xpf = XPathFactory.newInstance(XPathConstants.DOM_OBJECT_MODEL);
                     XPath xpath = xpf.newXPath();
                     xpath.compile("join(1, 2, 3)");

                     System.out.println("OK.");
                 } catch (Exception e) {
                     System.out.print("Failed: ");
                     e.printStackTrace();
                 }
             }
        }
        --------------------------------------------------------------------------
        % java -showversion test
        java version "1.5.0-beta"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32)
        Java HotSpot(TM) Client VM (build 1.5.0-beta-b32, mixed mode)

        case01 - Failed: javax.xml.xpath.XPathExpressionException: javax.xml.transform.TransformerException:
        Could not find function: join
        at com.sun.org.apache.xpath.internal.jaxp.XPathImpl.compile(XPathImpl.java:266)
        at Test.case01(Test.java:16)
        at Test.main(Test.java:8)
        Caused by: javax.xml.transform.TransformerException: Could not find function: join
        at com.sun.org.apache.xpath.internal.compiler.XPathParser.error(XPathParser.java:640)
        at com.sun.org.apache.xpath.internal.compiler.XPathParser.FunctionCall(XPathParser.java:1487)
        at com.sun.org.apache.xpath.internal.compiler.XPathParser.PrimaryExpr(XPathParser.java:1426)
        at com.sun.org.apache.xpath.internal.compiler.XPathParser.FilterExpr(XPathParser.java:1325)
        at com.sun.org.apache.xpath.internal.compiler.XPathParser.PathExpr(XPathParser.java:1258)
        at com.sun.org.apache.xpath.internal.compiler.XPathParser.UnionExpr(XPathParser.java:1216)
        at com.sun.org.apache.xpath.internal.compiler.XPathParser.UnaryExpr(XPathParser.java:1122)
        at com.sun.org.apache.xpath.internal.compiler.XPathParser.MultiplicativeExpr(XPathParser.java:1043)
        at com.sun.org.apache.xpath.internal.compiler.XPathParser.AdditiveExpr(XPathParser.java:985)
        at com.sun.org.apache.xpath.internal.compiler.XPathParser.RelationalExpr(XPathParser.java:910)
        at com.sun.org.apache.xpath.internal.compiler.XPathParser.EqualityExpr(XPathParser.java:850)
        at com.sun.org.apache.xpath.internal.compiler.XPathParser.AndExpr(XPathParser.java:814)
        at com.sun.org.apache.xpath.internal.compiler.XPathParser.OrExpr(XPathParser.java:787)
        at com.sun.org.apache.xpath.internal.compiler.XPathParser.Expr(XPathParser.java:770)
        at com.sun.org.apache.xpath.internal.compiler.XPathParser.initXPath(XPathParser.java:163)
        at com.sun.org.apache.xpath.internal.XPath.<init>(XPath.java:200)
        at com.sun.org.apache.xpath.internal.XPath.<init>(XPath.java:236)
        at com.sun.org.apache.xpath.internal.jaxp.XPathImpl.compile(XPathImpl.java:259)
        ... 2 more
        --------------------------------------------------------------------------

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

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  jsuttorsunw Jeff Suttor (Inactive)
                  Reporter:
                  evgsunw Evg Evg (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: