[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: xslt 2. index-of, nodes

Subject: Re: xslt 2. index-of, nodes
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 3 Jul 2003 12:22:30 +0100
xslt indexof
Dave,

> Hence I need to find out, roughly
>  whether the context-item() is 1,2,3,4 etc, in
>  the sequence of all loc elements with identical hl, side and pos
> attributes.

I think that using the same method as you'd use in XSLT 1.0 would
work:

  count(preceding::loc[@hl = $context/@hl and
                       @side = $context/@side and
                       @pos = $context/@pos]) + 1

> variable name='set'
>   select='//loc[@hl=$context/@hl and @side=$context/@side and
> @pos=$context/@pos]'
>
> What's not working as I expect  is index-of($set,context-item())
>   since (I guess) it uses typed value, not the node itself?
> (Always returns 1)

That's right. The arguments to index-of() are atomised to atomic
values, so you're getting the index of the <loc> element with the same
typed value as the <loc> element you're looking at.

Of course there might be other, better, methods depending on how
you're processing the <loc> elements. For example, perhaps you could
use XSLT 2.0's grouping mechanism to process all the <loc> elements in
the group at once, and then just use position().

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.