Re: AW: [xsl] Special processing for the first process of an element

Subject: Re: AW: [xsl] Special processing for the first process of an element
From: Geert Josten <Geert.Josten@xxxxxxxxxxx>
Date: Thu, 11 Nov 2004 23:52:22 +0100
Peter Hickman wrote:

<xsl:template match="result">
<xsl:choose>
<xsl:when test="preceding::result">
<result class="rest"><xsl:apply-templates select="*|text()" /></result>
</xsl:when>
<xsl:otherwise>
<result class="first"><xsl:apply-templates select="*|text()" /></result>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

If using the preceding axis is getting slow on large XML documents, you could switch to keys.


(top-level)
<xsl:key name="results" match="result" use="'all'" />

(result template)
<xsl:when test="generate-id(.) = generate-id(key('results', 'all')[1])">
   ... first ...
</xsl:when>

Cheers,
Geert

Current Thread