xsl-list
[Top] [All Lists]

Re: [xsl] Relationships in for-each statement

2006-09-08 10:24:47

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.


--~------------------------------------------------------------------
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>
--~--