This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Limiting a FOR-EACH loop


thanks for the reply brian martinez. i am not able to get this to work
though. the for loop does not iterate at all. r u sure this should work?

          <xsl:for-each select="/search/results/*[position() &lt;= $x]">

thanks again,

-g


-----Original Message-----
From: owner-xsl-list@lists.mulberrytech.com
[mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of Martinez,
Brian
Sent: Wednesday, September 18, 2002 1:10 PM
To: 'xsl-list@lists.mulberrytech.com'
Subject: RE: [xsl] Limiting a FOR-EACH loop


> From: Gurnam Bedi [mailto:Gurnam.Bedi@teachscape.com]
> Sent: Wednesday, September 18, 2002 10:04 AM
> Subject: [xsl] Limiting a FOR-EACH loop
>
>
> How do I ensure that a FOR-EACH loop only iterates over the
> first x number
> of elements. Or more generally, how can I read the values of
> first x number
> of elements in a certain node [ex: /SEARCH/RESULTS] and
> ignore the rest of
> the elements in the /SEARCH/RESULTS (where x itself is the
> value-of another
> element)?

You could try (assuming x has been defined already):

<xsl:for-each select="/search/results/*[position() &lt;= $x]">
  <xsl:value-of select="."/> <!-- or copy-of if you need the nodes -->
</xsl:for-each>

So if x = 2, only the values of the first two child elements would be
output.

hth,
b.

| brian martinez                              brian.martinez@trip.com |
| senior gui programmer                                  303.708.7248 |
| trip network, inc.                                 fax 303.790.9350 |
| 6436 s. racine cir.                             englewood, co 80111 |
| http://www.cheaptickets.com/                   http://www.trip.com/ |

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]