Re: [xsl] working out where the last() is

Subject: Re: [xsl] working out where the last() is
From: "andrew welch" <andrew.j.welch@xxxxxxxxx>
Date: Fri, 6 Oct 2006 11:30:51 +0100
On 10/6/06, Robert Walpole <robert.walpole@xxxxxxxxxxxx> wrote:

I have some XML data which contains an areaserved node as follows:

        <district name="South Hams">
                <town name="Dartmouth">
                        <settlement name="Kingswear"/>
                <town name="Totnes"/>
        <district name="Torbay"/>

I am trying to write some XSLT to transform this to a list as follows:

Kingswear, Totnes, Torbay

In 2.0 you can use:

string-join(//*[not(*)]/@name, ', ')

In 1.0 you don't have the string-join() function so you need to add
the comma yourself:

<xsl:for-each select="//*[not(*)]/@name">
	<xsl:value-of select="."/>
	<xsl:if test="position() != last()">, </xsl:if>


Current Thread