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

Multi-predicate XPath expressions incorrectly evaluated in XSLT templates

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      Host architecture and OS independent.
      Java 8 .. 20+EA-27 inclusive.


      A DESCRIPTION OF THE PROBLEM :
      Comprehensive details in the attached zip file.

      Synopsis: XPath expressions with multiple predicates ("x[a][b][c]") are evaluated correctly through the XPath APIs but incorrectly when used as XSLT template selectors.

      This appears similar to a very old bug in the Xalan code which was ported to the JDK codebase for Java 7, and which is probably the reason XPath works. However, the XSLT case also works in the most recent (2014, 2.7.2) Xalan-J codebase, so it's possibly a later fix that wasn't ported across.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      There's a script in the the attached zip file and you can run to reproduce the working and failing cases, with and without a classpath version of Xalan-J.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      XPath in XSLT should match the same elements as XPath in isolation.
      ACTUAL -
      Evaluation of XPath in XSLT sometimes gives incorrect results.

      ---------- BEGIN SOURCE ----------
      See the attached zip file
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Putting the 2014-era Xalan-J on the classpath gives the correct results.

      It's possible, but disruptive and obviously not very confidence-inspiring, to rewrite the XPath expression until you find something that gives the correct answer.

      FREQUENCY : always


            joehw Joe Wang
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: