The XPath 2.0 parser/handler incorrectly counts a node as one of its own following-sibling:: (as though it were a combination of following-sibling:: and self::)
public class dummy {
public String toString() {
String test = "bad example";
return test;
}
}
//BlockStatement/following-sibling::BlockStatement
The above code should return one match, for line 4. With xpath version 1.0 it does. With xpath version 2.0 it returns both lines 3 and 4.
This leads to problems with xpaths that are intended to tell if a BlockStatement with certain properties immediately follows a BlockStatement with certain other properties, e.g.
//BlockStatement[descendant::VariableDeclaratorId]/following-sibling::BlockStatement[1]//ReturnStatement
...should match the return statement only if the action just before it was the creation of a variable, but in xpath 2.0 does not because the following-sibling::BlockStatement matches both and then the [1] restricts it to the initial BlockStatement instead of the first BlockStatement after it.
This will be fixed with the next release.