Re: [xsl] Limiting a FOR-EACH loop

Subject: Re: [xsl] Limiting a FOR-EACH loop
From: "Vasu Chakkera" <vasucv@xxxxxxxxxxx>
Date: Wed, 18 Sep 2002 22:50:50 +0000

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: [xsl] 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