Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using variables in XSLT

0 views
Skip to first unread message

Fran García

unread,
Jan 12, 2004, 7:42:05 AM1/12/04
to
I惴 trying to show a limited number of feeds from a xml document. For
example I have the next document:

<catalog>
<cd>
<artist>Bob Dylan</artist>
<name>The first lp</name>
<cd>
<cd>
<artist>Bob Dylan</artist>
<name>The second lp</name>
<cd>
<cd>
<artist>Bob Dylan</artist>
<name>The third lp</name>
<cd>
<cd>
<artist>Bob Dylan</artist>
<name>The fourth lp</name>
<cd>
<cd>
<artist>Bob Dylan</artist>
<name>The fifth lp</name>
<cd>
</catalog>


and I have too a xslt document for transform the output. I惴 using a loop
<xsl:for-each select="cd/artist"> for show all the information about cd愀,
but now I惴 only want to show the first 3 cd. How can I do this?

Joe Fawcett

unread,
Jan 12, 2004, 8:44:35 AM1/12/04
to
"Fran García" <fga...@ua.es> wrote in message
news:btu4kv$rr6$1...@news.ua.es...
> I´m trying to show a limited number of feeds from a xml document. For

> example I have the next document:
>
> <catalog>
> <cd>
> <artist>Bob Dylan</artist>
> <name>The first lp</name>
> <cd>
> <cd>
> <artist>Bob Dylan</artist>
> <name>The second lp</name>
> <cd>
> <cd>
> <artist>Bob Dylan</artist>
> <name>The third lp</name>
> <cd>
> <cd>
> <artist>Bob Dylan</artist>
> <name>The fourth lp</name>
> <cd>
> <cd>
> <artist>Bob Dylan</artist>
> <name>The fifth lp</name>
> <cd>
> </catalog>
>
>
> and I have too a xslt document for transform the output. I´m using a loop
> <xsl:for-each select="cd/artist"> for show all the information about cd´s,
> but now I´m only want to show the first 3 cd. How can I do this?
>
Use position() function:

<xsl:for-each select="cd[position() &lt;= 3]]/artist">

--

Joe


0 new messages