Project

Profile

Help

possible xpath2 bug and work around

Added by Anonymous over 19 years ago

Legacy ID: #3113672 Legacy Poster: jonwilliford (jonwilliford)

Using saxon8.jar when I try to execute: <xsl:copy-of select="$currnode/m:mprescripts/preceding-sibling::* [ (fn:position() mod 2 eq 1) and (fn:position() ne fn:last()) and (not(self::m:none))]"/> I get the error: java.lang.ArrayIndexOutOfBoundsException: -1 at net.sf.saxon.tinytree.PrecedingSiblingEnumeration.next(PrecedingSiblingEnumeration.java:35) In order to get it to work I have to avoid using the fn:last() function. I do this by declaring a variable that counts all the children before the copy-of instruction and replacing fn:last() with this variable: <xsl:variable name="num-preceding-sib" select="fn:count($currnode/m:mprescripts/preceding-sibling::)"/> <xsl:copy-of select="$currnode/m:mprescripts/preceding-sibling:: [ (position() mod 2 eq 1) and (position() ne $num-preceding-sib) and (not(self::m:none))]"/> Jonathan


Replies (2)

RE: possible xpath2 bug and work around - Added by Anonymous over 19 years ago

Legacy ID: #3113718 Legacy Poster: Michael Kay (mhkay)

Thanks for reporting this. Can you put together a repro (stylesheet plus source document) that demonstrates the problem? Otherwise it's rather difficult to investigate (it may well depend on aspects of the stylesheet outside the code fragment you've sent me). It's definitely a bug, and assuming this is on Saxon 8.4, it doesn't look like one that I know about. Thanks.

RE: possible xpath2 bug and work around - Added by Anonymous over 19 years ago

Legacy ID: #3114106 Legacy Poster: Michael Kay (mhkay)

I've logged the bug and a source patch to fix it at: https://sourceforge.net/tracker/index.php?func=detail&amp;aid=1188364&amp;group_id=29872&amp;atid=397617 Michael Kay

    (1-2/2)

    Please register to reply