Appendix C.3 of the Functions and Operators spec shows how to write this as
a userwritten function:
XSLT implementation
<xsl:function name="eg:indexofnode" as="xs:integer*">
<xsl:param name="sequence" as="node()*"/>
<xsl:param name="srch" as="node()"/>
<xsl:foreach select="$sequence">
<xsl:if test=". is $srch">
<xsl:sequence select="position()"/>
</xsl:if>
</xsl:foreach>
</xsl:function>
XQuery implementation
declare function eg:indexofnode($sequence as node()*, $srch as node()) as
xs:integer*
{
for $n at $i in $sequence where ($n is $srch) return $i
}
Regards,
Michael Kay
> Original Message
> From: saxonhelpadmin@...
> [mailto:saxonhelpadmin@...] On Behalf Of Memey
> Sent: 25 June 2004 15:41
> To: saxonhelp@...
> Subject: [saxon] function: sequence()
>
> Hi,
>
> Just a small question. Is there a function that's concerned
> about sequence of
> nodes in Saxon? Like one which returns the orders of nodes.
>
> For instance, assume a sequence
> "<a>AAA</a><b>BBB</b><c>CCC</c><d>DDD</d>"
>
> Then the function can return something like:
>
> <a>AAA</a> => 1;
> <b>BBB</b> => 2;
> <c>CCC</c> => 3;
> <d>DDD</d> => 4;
>
> If so, how can it be invoked in Saxon?
>
> Thank you so much in advance for any help.
>
>
> Cheers,
> W.Jirapanthong
>
> Capital One Classic
> Mastercard
> 60 second
> response online. http://mocda.com/1/c/681064/117934/307081/307081
>
> AOL users go here
> http://mocda.com/1/c/681064/117934/307081/307081
>
>
