Not sure about the exact scope of the problem, but the attached test case fails.
XPath in question: "id('a')/div".
Created attachment 12804 [details]
Created attachment 12897 [details]
Actually implement Path::doEvaluate().
Comment on attachment 12897 [details]
Looks fine, r=me.
Committed revision 19388.