[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: working out where the last() is

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

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

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

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>
</xsl:for-each>

cheers
andrew

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.