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]

Re: catching the last node still satisfying a condition


Ainsi parlait Dimitar Peikov :
[..]
> > Considering the following situation
> > <foo>
> >   <foo id="foo1">
> >     <bar/>
> >   </foo>
> >   <foo id="foo2">
> >   <bar/>
> >   </foo>
> >   <foo id="foo3>
> >   </foo>
> > </foo>
> > i would like to catch foo2 with limit = 2 or 3, and foo1 with limit = 1
>
> foos/foo[position() &lt; limit]/bar
Inside a for-each to catch only the last, that's OK: 
<xsl:for-each select="foos/foo[bar and position() &lt; limit]">
  <xsl:if test="position()=last()">
    <xsl:apply-template select="."/>
  </xsl:if>
</xsl:for-each>
Thanks
-- 
Guillaume Rousse <rousse@ccr.jussieu.fr>
GPG key http://lis.snv.jussieu.fr/~rousse/gpgkey.html

 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]