[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: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 13 Jan 2006 13:33:35 GMT
Re:  Selecting the first item from a 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





Michael meant that to be a meta-expression with SEQ and N standing for
Xpath expressions, but if you take them as real examples with SEQ and N
being Xpath expressions selecting elements SEQ and N respectively then
you have an example where SEQ[N] and subsequence(SEQ, N, 1) are not
equivalent, as in the first  N selects children of the current node (and
may have a different value for each SEQ element) and in the second N selects
an N element child from the current node (which will then be a sibling
not a child of SEQ) and this value will be cast to an integer.

so 
<x>
  <N>1</N>
   <SEQ>1<N>6</N></SEQ>
   <SEQ>2</SEQ>
   <SEQ>3<N>3</N></SEQ>
</x>


SEQ[N] selects the first and third SEQ (as they have N children)
SEQ[number(N)] selects the third SEQ (as that is the only one with an N
   child equal to its position())
SEQ[N] selects the first SEQ child as N selects an element whose value
     can be cast to the integer 1.




David








________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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.