XalanJ2
  1. XalanJ2
  2. XALANJ-1434

org.apache.xpath.axes.AxesWalker getLastPos: duplicate predicate testing

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.7
    • Fix Version/s: 2.7.1
    • Component/s: XPath
    • Labels:
      None
    • Environment:
      Operating System: All
      Platform: All

      Description

      In class org.apache.xpath.axes.AxesWalker method getLastPos there's a fragment
      of code:
      walker.setPredicateCount(walker.getPredicateCount() - 1);

      Thus, in expression x[last() != position()][true()] first predicate is checked
      twice.

      XML sample:
      <?xml version="1.0" encoding="UTF-8"?>
      <doc>
      <item>1</item>
      <item>2</item>
      <item>3</item>
      </doc>

      Result of
      <xsl:copy-of select="/doc/item[last() != position()][true()]"/>

      is
      <item>1</item>

      and should be
      <item>1</item>
      <item>2</item>

      XSL work-around:
      <xsl:copy-of select="(/doc/item[last() != position()])[true()]"/>

      Java code fix: replace code line in org.apache.xpath.axes.AxesWalker getLastPos:
      walker.setPredicateCount(walker.getPredicateCount() - 1);
      to
      walker.setPredicateCount(this.m_predicateIndex);

        Activity

        Hide
        david_marston added a comment -

        New tests position112 and 113 reveal this bug for forward and reverse axes.

        Show
        david_marston added a comment - New tests position112 and 113 reveal this bug for forward and reverse axes.
        Hide
        Dimitry E Voytenko added a comment -

        Created an attachment (id=5281)
        Patches for both org.apache.xpath.AxesWalker and ReverseAxesWalker

        Show
        Dimitry E Voytenko added a comment - Created an attachment (id=5281) Patches for both org.apache.xpath.AxesWalker and ReverseAxesWalker
        Hide
        Brian Minchau added a comment -

        This JIRA issue was created when bugzilla was used to track issues, the original bug is at:
        http://issues.apache.org/bugzilla/show_bug.cgi?id=17400

        When bugzilla was used there was no checkbox to grant Apache any rights.

        Dmitry attached the patch to the bugzilla bug with the intention that it be applied to the Apache code, otherwise he wouldn't have attached it to the bugzilla report.

        Also the patch is not substantial, it is two small one line fixes, to fix an off by one problem so I don't think that any more dilligence be done on this one, it is OK to apply the patch.

        Show
        Brian Minchau added a comment - This JIRA issue was created when bugzilla was used to track issues, the original bug is at: http://issues.apache.org/bugzilla/show_bug.cgi?id=17400 When bugzilla was used there was no checkbox to grant Apache any rights. Dmitry attached the patch to the bugzilla bug with the intention that it be applied to the Apache code, otherwise he wouldn't have attached it to the bugzilla report. Also the patch is not substantial, it is two small one line fixes, to fix an off by one problem so I don't think that any more dilligence be done on this one, it is OK to apply the patch.
        Hide
        Kevin Cormier added a comment -

        I have reviewed and tested the patch. Brian Minchau has applied the patch because although I've just become a committer, I don't have my SVN access working yet.

        Show
        Kevin Cormier added a comment - I have reviewed and tested the patch. Brian Minchau has applied the patch because although I've just become a committer, I don't have my SVN access working yet.
        Hide
        Brian Minchau added a comment -

        Changing affected version to 2.7, and fixed version to 2.7.1

        Show
        Brian Minchau added a comment - Changing affected version to 2.7, and fixed version to 2.7.1
        Hide
        Brian Minchau added a comment -

        Would the originator of this issue please verify that this issue is fixed in the 2.7.1 release, by adding a comment to this issue, so that we can close this issue.

        A lack of response by February 1, 2008 will be taken as consent that we can close this resolved issue.

        Regards,
        Brian Minchau

        Show
        Brian Minchau added a comment - Would the originator of this issue please verify that this issue is fixed in the 2.7.1 release, by adding a comment to this issue, so that we can close this issue. A lack of response by February 1, 2008 will be taken as consent that we can close this resolved issue. Regards, Brian Minchau

          People

          • Assignee:
            Unassigned
            Reporter:
            Dimitry E Voytenko
            Reviewer:
            Kevin Cormier
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development