position()!=last() in pattern fails
The Saxon XSLT and XQuery processor, developed by Saxonica
Brought to you by:
mhkay
A match pattern containing the predicate [position()!=last
()] or [position()<last()] gives the wrong answer: if
selects the nodes where position()=last(), and fails to
select those where position()!=last().
Applies to 6.5.2, 7.1, and 7.2.
Circumvention: declare a higher-priority template rule
with the pattern [position()=last()], and leave this filter off
the rule for matching other nodes.
Source fix (tested on Saxon 7.2):
(a) in expr.IsLastExpression, add the method
public boolean getCondition() { return condition; }
(b) in pattern.LocationPathPattern, around line 108 in
Saxon 7.2 or line 90 in Saxon 6.5.2, change the test:
if (nodeTest.getItemType() == Type.ELEMENT && numberOfFilters==1 && filters[0] instanceof IsLastExpression)
to:
if (nodeTest.getItemType() == Type.ELEMENT && numberOfFilters==1 && filters[0] instanceof IsLastExpression && ((IsLastExpression)filters[0]).getCondition())
Source code fixed in both branches.
Test case added: pos64
Logged In: YES
user_id=251681
Cleared in 7.3