cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Cordes <mcord...@maine.edu>
Subject Re: [xslt] element counting
Date Mon, 12 Jun 2000 09:30:50 GMT
Mariusz,

Try the XPath count( <node-set> ) function.  I think this will do what 
you want.  It is described in section 4.1 of the latest XPath spec or 
page 434 of "XSLT Programmer's Reference" by Michael Kay.

( This is slightly off topic, you might wanna try www.mulberrytech.com's
list dedicated to XSLT or grab Kay's book, I highly recommend it. )

-matt


On Mon, Jun 12, 2000 at 03:45:19PM +1200, Mariusz Nowostawski wrote:
> Sorry for being slightly off topic here, but is there any other way to
> count (get the number of) particular children of a given element other
> than iterating through those children and grabing the last element
> position()?
> 
> At the moment I am doing:
> 
> <xsl:for-each select="someTag">
>    <xsl:if test="position()=last()">
>      do smth with <xsl:value-of select="position()"/>
>    </xsl:if>
> </xsl:for-each>
> 
> but it seems to me kind of way around. 
> I do not know how to build expression which returns the position of the
> last "someTag" element, is it possible?
> I have read about <xsl:number>, but I could not make it to work either in
> this case, I do not want to "iterate", I just want the total number.
> 
> Any suggestions?
> 
> --
> Mariusz
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
> 

Mime
View raw message