Re: [xsl] Just the first 'x' elements within a for-each

Subject: Re: [xsl] Just the first 'x' elements within a for-each
From: Simon.Fairey@xxxxxx
Date: Tue, 18 Mar 2003 10:33:16 +0000
Hi,

This doesn't seem to want to work whereas using:

<xsl:if test="position() &lt;= 2">

within the for-each does? Might this be something to do with the XSL 
parsing in XML Spy 5?

Oh and I had a good look around but couldn't find a simple description for 
'declarative programming'?
(I'm originally from an engineering background so no formal computer 
science background)

Cheers

Si





Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
17/03/2003 17:42
Please respond to Jeni Tennison

 
        To:     Simon.Fairey@xxxxxx
        cc:     xsl-list@xxxxxxxxxxxxxxxxxxxxxx
        Subject:        Re: [xsl] Just the first 'x' elements within a for-each


Hi Simon,

> I've tried numerous connotations of for-each loops, recursive
> functions etc but for the life of me I can't seem to get something
> which will only print/process the first 'x' (in my case x is 2)
> elements and then bail out of the for-each or just simply ignore the
> remaining ones found.

In declarative programming, you can't "bail out". Instead, try
selecting only the elements that you want to process:

  <xsl:for-each select="*[position() &lt;= 2]">
    ...
  </xsl:for-each>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/









**********************************************************************************
This email may contain confidential material. If you were not an
intended recipient, please notify the sender and delete all copies.
We may monitor email to and from our network.


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


Current Thread