[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Limiting a FOR-EACH loop

Subject: RE: Limiting a FOR-EACH loop
From: "Wes Kubo" <wkubo@xxxxxxxxxxxxx>
Date: Wed, 18 Sep 2002 11:54:09 -0700
xsl for each limiting
I tried it out and it worked...no prob. Have you added the other necessary
elements?, e.g.

<xsl:template match="/">
  <xsl:variable name="x" select="'4'"/>
  <xsl:for-each select="/search/results/*[position() &lt;= $x]">
    <xsl:copy-of select="."/>
  </xsl:for-each>
</xsl:template>

Wes



-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Gurnam Bedi
Sent: Wednesday, September 18, 2002 11:13 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: 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@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Martinez,
Brian
Sent: Wednesday, September 18, 2002 1:10 PM
To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
Subject: RE:  Limiting a FOR-EACH loop


> From: Gurnam Bedi [mailto:Gurnam.Bedi@xxxxxxxxxxxxxx]
> Sent: Wednesday, September 18, 2002 10:04 AM
> Subject:  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@xxxxxxxx |
| 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



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


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.