Although it's clear from these responses that there are solutions to these
requirements, I have always felt the need for higher order operators to
achieve this effect:
$seq[>>EXP] everything in $seq after the first item that satisfies EXP
$seq[>>=EXP] everything in $seq after and including -"-
$seq[<<EXP] everything in $seq before the first item that satisfies EXP
$seq[<<=EXP] everything in $seq before and including -"-
They're available in Saxon and EXSLT to some extent in the form xx:leading()
and xx:trailing().
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Vladimir Nesterovsky [mailto:vladimir(_at_)nesterovsky-bros(_dot_)com]
Sent: 18 December 2008 16:06
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] selecting from sequences
- the position of the first b?
<!-- 0 means that there is no value. --> <xsl:variable
name="index" as="xs:integer" select="
(
for $i in 1 to count($seq) return
$seq[$i][self::b],
0
)[1]"/>
- everything before the first b
<xsl:sequence select="subsequence($seq, 1, $index)"/>
- everything from the first b to the end
<xsl:sequence select="subsequence($seq, $index)"/>
Vladimir Nesterovsky
http://www.nesterovsky-bros.com
----- Original Message -----
From: "Ruud Grosmann" <r(_dot_)grosmann(_at_)sdu(_dot_)nl>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Thursday, December 18, 2008 17:28
Subject: [xsl] selecting from sequences
hi group,
I have question which must have been on this list before,
but I can't
find the answer.
In my style sheet I make a selection of the elements and
pass that to a
template. In that template I can reference this sequence as $seq.
Selecting from $seq appears to be not that easy, because I
can't use
axes. Axes have a document scope whereas I want to do
something within
the sequence.
If for example $seq contains elements a, b, c, b, e:
how do I select
- everything before the first b
- everything from the first b to the end
- the position of the first b?
As $seq[self::b][1]/preceding-sibling::* is not good
because it possibly
selects element outside the sequence, but are
preceding-siblings in the
document.
Thanks in advance,
Ruud
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--