[xsl] Searching the last element

Subject: [xsl] Searching the last element
From: Andreas Grytz <agrytz@xxxxxxxxxxxxx>
Date: Fri, 25 Apr 2003 11:27:45 +0200
Hi all,

I got stuck with a problem, searching the last element in a document.
The simpliefied structure of the XML-Tree looks like this:

<text>
<p>First paragraph.</p>
<p>Next paragraph.</p>
<p>Last paragraph.</p>
</text>

I tried the followoing to add a star "*" at the end of the text from the
last p-element:

<xsl:template match="p">
  <p><xsl:apply-templates/>
	<xsl:if test="/text/p[position()=last()]">
	<xsl:text> *</xsl:text>
	</xsl:if>
  </p>
</xsl:template>

But I get -- surprise, surprise -- a star beyond every paragraph. Can
anybody point me in the right direction?

Regards,

	Andreas

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


Current Thread