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

RE: append values to a String

Subject: RE: append values to a String
From: "XSLList" <xsllist@xxxxxxxxxxxxx>
Date: Thu, 13 Feb 2003 12:08:57 -0500
xsl string append
Here's another variation, the only difference being the use
of normalize-space() to eliminate "empty" elements like <K1>  </K1>

There've been a couple of good posts comparing the different methods of
testing elements.  (Now if I could just figure out the syntax of axes...)

--Jeff

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl='http://www.w3.org/1999/XSL/Transform' >
<xsl:output method="xml" indent="yes"/>
	<xsl:template match="Sample">
		<xsl:variable name="csvlist">
			<xsl:for-each select="child::*[normalize-space()]">
				<xsl:value-of select="."/>
				<xsl:if test="position() != last()">
					<xsl:text>,</xsl:text>
				</xsl:if>
			</xsl:for-each>
		</xsl:variable>
	</xsl:template>
</xsl:stylesheet>

>Here's the xml:
>
><Sample>
>	<K1/>
>	<K2>something</K2>
>	<K3>something else</K3>
>	<K4/>
></Sample>
>
>I'd like to loop through all the children nodes under
><Sample>, find those
>have non-empty value, and construct a String with all those
>values append to
>each other with a "," delimiter in between them, i.e. the result String
>should look like:  "something,something else,".  And I need to
>assign this
>String to a variable since I need to use it elsewhere.


 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.