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

RE: Selecting the first item from a tokenized string

Subject: RE: Selecting the first item from a tokenized string
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 13 Jan 2006 14:22:50 -0000
xsl tokenized string
> Michael Kay wrote:
>
> > you can get the Nth item in a sequence using SEQ[N].
> > In the rare cases where that's inconvenient because
> > it changes the evaluation context, you can use
> > subsequence(SEQ, N, 1).
>
>   When can this happen?  Can you show an example?
>
>   Regards,
>
> --drkm
>

Suppose that you have a structure like this:

<e>
  <itemref nr="5"/>
  <itemref nr="7"/>
  <itemref nr="10"/>
</e>
<f>
  <item/>...
</f>

and you want to select the 5th, 7th, and 10th <item> elements.

You can't do

<xsl:for-each select="/e/itemref">
  <xsl:value-of select="/f/item[@nr]"/>

because the context inside the predicate is wrong.

But you can do

<xsl:for-each select="/e/itemref">
  <xsl:value-of select="subsequence(/f/item, @nr, 1)"/>

Of course there are other circumventions as well, involving variables or
current() - but it's nice to be aware of this alternative.

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: Florent Georges [mailto:darkman_spam@xxxxxxxx]
> Sent: 13 January 2006 13:14
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE:  Selecting the first item from a tokenized string
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> ______________________________________________________________
> _____________
> Nouveau : tiliphonez moins cher avec Yahoo! Messenger !
> Dicouvez les tarifs exceptionnels pour appeler la France et
> l'international.
> Tilichargez sur http://fr.messenger.yahoo.com

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.