You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Voytenko, Dimitry" <dv...@sectordata.com> on 2003/02/22 05:37:53 UTC

AxesWalker.getLastPos bug

Hi,

While I was looking into "position() != last()" issue, I noticed that in
class org.apache.xpath.axes.AxesWalker method getLastPos there's a fragment
of code:
	walker.setPredicateCount(walker.getPredicateCount() - 1);

It looks suspicsous, b/c last() function is not necessarily called in the
last predicate. It looks like it should be:
	walker.setPredicateCount(walker.m_predicateIndex);

As an example, for XML:
<?xml version="1.0" encoding="UTF-8"?>
<doc>
   <item>1</item>
   <item>2</item>
   <item>3</item>
</doc>

Two Xalan instructions should return the same result:
        <xsl:copy-of select="/doc/item[last() != position()]"/>
and
        <xsl:copy-of select="/doc/item[last() != position()][true()]"/>

Instead, first example returns (correct):
   <item>1</item>
   <item>2</item>

and second (incorrect):
   <item>1</item>

This happens most probably b/c of checking [last() != position()] twice.

XSL work-around would be to rewrite second instruction as:
        <xsl:copy-of select="(/doc/item[last() != position()])[true()]"/>

I'm sure this fix will solve this exact problem (I tried to recompile and
run -- it was fine), but not sure there won't be any side-affects.

Should I register this as a bug in bugzilla?

Thanks,
Dimitry



_____________________________________________________
Sector Data, LLC, is not affiliated with Sector, Inc., or SIAC