Altova Mailing List Archives

RE: [xsl] Searching the last element

From: TSchutzerWeissmann@----------------
Date: 4/25/2003 2:56:00 AM
Hi Andreas

> > >   <p><xsl:apply-templates/>
> > > 	<xsl:if test="/text/p[position()=last()]">
> > 
> > This tests if there is a last "p" in the whole document and 
> will return true every time. You want
> > 
> >   <xsl:if test="position() = last()">
> > 
> I am sorry, this solution didn't work. But thanks for explaining me,
> what has been wrong with my example.

it's only going to work if you do <xsl:apply-templates select="p"/> in
<text> context. 

If you just do <xsl:apply-templates/> you're applying templates to the whole
document, which will change the values of position() and last(). They'll
only give the values you want if you're just applying templates to this set
of <p>s

Tom SW

 XSL-List info and archive:


These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.