|
Subject: Re: [xsl] Selecting the first item from a tokenized string From: David Carlisle <davidc@xxxxxxxxx> Date: Fri, 13 Jan 2006 13:33:35 GMT |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] Selecting the first item , Florent Georges | Thread | Re: [xsl] Selecting the first item , David Carlisle |
| Re: [xsl] XML to XML via XSLT, and , David Carlisle | Date | Re: [xsl] Selecting the first item , David Carlisle |
| Month |