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

working out where the last() is

Subject: working out where the last() is
From: "Robert Walpole" <robert.walpole@xxxxxxxxxxxx>
Date: Fri, 6 Oct 2006 11:13:43 +0100
 working out where the last() is
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 other words I want to output the name attribute of elements that have
no children and I want these names to be seperated by a comma. I can
output the attributes ok but my problem is trying to prevent the code
putting out a comma at the end of the list, given that I don't know
whether the end of the list will be a settlement, town or district. I
have tried using last() like this:

<xsl:if test="position() != last()">,&#160;</xsl:if>

but this only works on the context node, so in this case Kingswear,
Totnes and Torbay are all the last and none of them get a comma!

Any ideas anyone?

Many Thanks
Rob Walpole
(robert.walpole@xxxxxxxxxxxx)

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.