|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: append values to a String
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








