[xquery-talk] index-of() behavior

Joe Wicentowski joewiz at gmail.com
Thu Mar 19 11:28:19 PST 2009

Hi all,

Can anyone shed some light on the following question?  I'm trying to
use fn:index-of() to derive the sequential appearance of elements --
in this case, I have 2 <y> elements, and I want index-of() to return
the values 1 and 2:

let $content :=
        <y n="1">z</y>
        <y n="2">z</y>
for $child in $content/y
let $index := fn:index-of($content/y, $child)

I expected this to return:


but instead it returns:

   <result>1 2</result>
   <result>1 2</result>

If, on the other hand, I change $content to

        <y n="1">z1</y>
        <y n="2">z2</y>

Then I get my desired result.  Shouldn't fn:index-of() index against
the unique <y> nodes rather than their text content?  I've tested this
in eXist 1.3 and in oXygen (using Saxon 9).


More information about the talk mailing list