Uploaded image for project: 'XalanJ2'
  1. XalanJ2
  2. XALANJ-1434

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

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.7
    • 2.7.1
    • XPath
    • None
    • Operating System: All
      Platform: All
    • 17400
    • PatchAvailable

    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);

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            dvoytenko@sectorbase.com Dimitry E Voytenko
            Kevin Cormier Kevin Cormier
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment