[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: "Vasu Chakkera" <vasucv@xxxxxxxxxxx>
Date: Wed, 18 Sep 2002 22:50:50 +0000
xsl loop 5 elements

Dear Gurnam,
You havent explained your problem properly..
I am giving u a solution that limits the no of elements the for-each processes. You can do this using position() function..
the following is an example


xml file
--------

<elements>
<element>element1</element>
<element>element2</element>
<element>element3</element>
<element>element4</element>
<element>element5</element>
<element>element6</element>
<element>element7</element>
<element>element8</element>
</elements>

xsl
---

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:for-each select="/elements/element[position() &lt;=5]">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>


this will print the values of the first 5 elements..
I dont know if this gives a lead to your problem..please get back if you have any querries


Thanks
Vasu


From: "Gurnam Bedi" <Gurnam.Bedi@xxxxxxxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject:  Limiting a FOR-EACH loop
Date: Wed, 18 Sep 2002 12:04:27 -0400

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)?

Thanks

-G


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






_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com


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.