[xsl] Realising when you hit the last match?
Subject: [xsl] Realising when you hit the last match?|
From: "Aaron McGrath" <aaronmcgrath@xxxxxxxxxxx>
Date: Thu, 03 Mar 2005 15:07:10 +0000
Hit a bit of a problem...
Just can't seem to figure out when I am processing the last match.
Okay, goes a bit like this:
XML sample (please forgive the syntax, hopefully it paints a clear enough
Now, what I want to do is to find all headings that either have a class of
'2000' or have a class of '2003'.
Then I would like to process them all together and when I hit the last one
do something special.
Exactly what I want to do is to output the class value when a '2000' or
'2003' is matched. But I would like them seperated with a comma. This
means that when I hit the last one I do not want to whack out a comma.
Okay... sounds simple right?
It did to me too...
Until I realized that there might not be any '2000' or there might not be
The problem is then even more prominent when you consider that I am actually
dealing with about 10 different class values. I have just done two here to
give an example.
I am doing something like this:
<xsl:apply-templates select="//pdxc2:heading[@class='2000'] |
//pdxc2:heading[@class='2003'] | //pdxc2:heading[@class='2008'] |
So I am only interested in '2000', '2003', '2008' and '2009'.
As I said there may be multiples or even none of each class, so I can't
guarantee that the last match of a class '2009' will be the last one to deal
I then have a template match for each class which then deals with the
This is where I get stuck. I have no idea how to know when I have hit the
last match which could be any of the classes above.
I am trying to get an output like this(according to the sample xml above):
Notice no comma on the end. Don't know about all of you, but aren't commas
in these situations always an a issue in any language!?
Thanks for any advice!