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

RE: Get a comma delimited string of nodenames.

Subject: RE: Get a comma delimited string of nodenames.
From: "Allan Jones" <allan.jones@xxxxxxxxxxxx>
Date: Thu, 3 Apr 2003 09:45:57 +0100
how to get a comma
|| Hi I have an xml like this:
|| <?xml version="1.0" ?>
|| <root>
||    <data_field1>value1</data_field1>
||    <data_field2>value1</data_field2>
||    <data_field3>value1</data_field3>
||    <data_field4>value1</data_field4>
|| </root>
|| I am trying to get back a string in the form:
|| "data_field1,data_field2,data_field3,data_field4"
|| Any help will be appreciated...
|| -Shishir

How about the xsl that does it? ;)

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
	<!-- root template match -->
	<xsl:template match="/root">
		<xsl:text>"</xsl:text>
		<!-- loop on each child of the current node (i.e. each
child of /root)
		<xsl:for-each select="*">
			<!-- get the local name of the element -->
			<xsl:value-of select="local-name()"/>
			<!-- insert a comma if it's not the last node
-->
			<xsl:if test="position() != last()">
				<xsl:text>,</xsl:text>
			</xsl:if>
		</xsl:for-each>
		<xsl:text>"</xsl:text>
	</xsl:template>
</xsl:stylesheet>

Hope that helps,

bRegards
Allan Jones

Tel:    0121 506 9111
Fax:    0121 506 9112
------------------------------------------------------------------------
----------------
HYFINITY LIMITED. Registered in England & Wales 4136884. Registered
Office:
Blythe Valley Innovation Centre, Central Boulevard, Blythe Valley Park,
Solihull, West Midlands, B90 8AJ. Tel: +44 (0)121 506 9111.

The information contained within this email, together with any
attachments,
is intended solely for the named recipient(s) and may contain privileged
and/or confidential information. If you receive this in error, please
notify
hyfinity limited immediately and delete this e-mail.

Any views or opinions represented in this e-mail are solely those of the
author and do not necessarily represent those of hyfinity or its
affiliate
companies.

Although this e-mail and its attachments have been scanned for the
presence
of computer viruses, hyfinity will not be liable for any losses as a
result
of any viruses being passed on. 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.