Petersen-san wrote:

I think calculations in positional predicates should be possible, but they raise an error (strangely, XPTY0004).

xquery version "3.0";

let $items :=
<items>
    <item>
        <target>
            <id>uuid-538a6e13-f88b-462c-a965-f523c3e02bbf</id>
            <start>3</start>
            <offset>4</offset>
        </target>
    </item>
    <item>
        <target>
            <id>uuid-538a6e13-f88b-462c-a965-f523c3e02bbf</id>
            <start>8</start>
            <offset>15</offset>
        </target>
    </item>
</items>

let $my-item := $items/*[3 - 1]/target/start/number()
    return $my-item



I've found that when the predicate is calculated, one must use position() to compare to the predicate.  Changing the assignment to:

let $my-item := $items/*[position()=3 - 1]/target/start/number()

should thus work.

I don't know if it's in the specification, but it's a general rule of thumb that I use.


--
Michael Westbay
Writer/System Administrator
http://www.japanesebaseball.com/