[xquery-talk] Context item dependant function in a step of a path expression

Pierrick Brihaye pierrick.brihaye at free.fr
Fri Aug 17 23:46:15 PDT 2007


With Saxon 8.9J, this XQuery :

let $a := <A/>
for $b in $a/B/string()
return string-length($b)

... returns an empty sequence (0, if wrapped by count()).

 From http://www.w3.org/TR/xpath-functions/#func-string :

> If no argument is supplied, the context item (.) is used as the
> default argument. The behavior of the function if the argument is
> omitted is exactly the same as if the context item had been passed as
> the argument.


> If $arg is the empty sequence, the zero-length string is returned.

I would thus have expected 0 as the result (1, if wrapped by count())
since I understand the context item as being "empty"... which is a 
concept which is not very conformant with the specs I conceed.

But, maybe, the processing of a context item dependant function when
there is no context item (which is not the same as being an "empty" 
context item and would thus be more conformant with the specs I guess) 
has to be skipped ; that would explain Saxon's behaviour (and make much 
sense BTW)...

In such a case, how would such a behaviour cope with the specs ? I 
couldn't find anything that would answer to this question.

Thank you for your answers,



More information about the talk mailing list