Re: [xsl] Relationships in for-each statement

Subject: Re: [xsl] Relationships in for-each statement
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 8 Sep 2006 18:24:20 +0100
> So, turning to elegance. Better to have that test inside the loop? Or
> just ahead of, triggered by a test="exists(key('findTitle', blah,
> blah))" ?

if I'm producing text or html or something I use the position()=1 method
(often as not). If I'm producing a proper structured xml nnested output
then you can't put the heading inside the loop as you need to do
something like

<xsl:if test="key(...)">
<section>
<head>...</head>
<xsl:for-each select="key(...)">
...
</xsl:for-each>
</section>
</xsl:if>


or since i see you're xslt2, you can often replace the whole shebang with

<xsl:for-each-group select="something" group-by="something else">
<section>
<head>...</head>
<xsl:for-each select="current-group()">
...
</xsl:for-each>
</section>
</xsl:for-each-group.

Current Thread