xsl-list
[Top] [All Lists]

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

2004-11-11 15:52:22
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>