Thanks.
Not even knowing of the existence of fn:filter or fn:for-each-pair I wrote just
now my version in old-fashioned-xquery
declare function common:node-index-of( $nodes as node()* , $node as node() ) as
xs:integer ?
{
for $n at $pos in $nodes
return
if( $n is $node )
then $pos
else ()
};
Signature may have to change if the same node exists > 1 time in a sequence
fn:for-each-pair looks like a really useful function ! I am often brain-stumped
trying to skip over every other node in a sequence having to write div 2 and
($i div2) + 1 etc
----------------------------------------
David A. Lee
[email protected]
http://www.xmlsh.org
-----Original Message-----
From: Michael Kay [mailto:[email protected]]
Sent: Sunday, January 05, 2014 4:48 PM
To: David Lee
Cc: [email protected]; [email protected]
Subject: Re: [xquery-talk] Collections - family relationships
On 5 Jan 2014, at 21:24, David Lee <[email protected]> wrote:
> Arg ... so your saying index-of causes a string atomization ?
> Ug. I know it wants item* and uses "eq" as the comparison but didn't
> realize that would stringify documents ...
Actually the function signature for index-of expects xs:anyAtomicType, which
means that if you supply a node it is atomized during the function call.
>
>
> Do you know of a sequence function that uses document or node ID's ?
>
union, intersect, difference....
The function index-of-node() is given as an example of a function you can write
yourself:
http://www.w3.org/TR/xpath-functions-30/#index-of-node
Generally the functions in this appendix were considered for inclusion in the
spec, and rejected because they can easily be implemented as user-defined
functions.
Michael Kay
Saxonica
_______________________________________________
[email protected]
http://x-query.com/mailman/listinfo/talk