Skip to content

Instantly share code, notes, and snippets.

@itod
Last active August 29, 2015 14:01
Show Gist options
  • Select an option

  • Save itod/3942c5a20abf37400356 to your computer and use it in GitHub Desktop.

Select an option

Save itod/3942c5a20abf37400356 to your computer and use it in GitHub Desktop.
NSXML XPath Bug
Source.xml:
<?xml version="1.0" encoding="utf-8" ?>
<doc id="foo"/>
Context Node:
/doc/@*
XPath:
(ancestor-or-self::node())[1]
Should return a node-set containing only the Root (Document) node. Apparently the parentheses should cause a document order sort because they signal the end of a PathExpr?.
Saxon 6.5 and 9.5 get this right. NSXML returns a node-set containing the Context Node
This Path should be equivalent, and it works in NSXML:
(ancestor-or-self::node()/.)[1]
Apparently the `/` is forcing the sort here.
Note that this is different from :
ancestor-or-self::node()[1]
which will return a node-set containing the Context Node in all three processors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment