On Sep 29, 2014, at 2:36 AM, Dirk Kirsten wrote:
... For the time being, rewriting the query seems the only option. I would suggest using
let $path1 := $doc/child::article/child::front /child::article-meta[child::aff[contains(.,"Japan")]] /child::article-id
which does produce the correct result. In fact, I would even argue it is a bit more elegant as you don't have to rewrite article-meta and the child::aff step seems to be a selector, so using a predicator is easier to read - at least to me, but this is, of course, also a matter of taste.
You are quite right, and my taste agrees with yours.
The unexpected results turned up in the evaluation of a solution to a homework problem offered by a student who is just learning XPath; I'll be happy when the students have learned enough XPath that we are able to talk, in class, about rewriting queries for clarity or to work around unexpected results.