[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: "Lars Huttar" <lars_huttar@xxxxxxx>
Date: Wed, 12 Feb 2003 14:57:51 -0600
append string xsl
Kudos to Jeni for an elegant and clear solution, as wonted.

In reply to Brian,

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Martinez,
> Brian
> Sent: Wednesday, February 12, 2003 10:20 AM
> To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
> Subject: RE:  append values to a String 
> 
...
> 
> <xsl:variable name="big-string">
>   <xsl:for-each select="Sample/*">
>     <xsl:if ". != ''">
>       <xsl:value-of select="."/>
>       <xsl:if "position() != last()">,</xsl:if>
>     </xsl:if>
>   </xsl:for-each>
> </xsl:variable>
> 
> Note that if the last child node is empty you'll still get a 
> trailing comma
> in your string--I'm sure there's a way to fix that but I have 
> a meeting to
> go to . . .  ;-)
> 
> hth,
> b.
> 

Mr. Wang didn't ask for the final comma to be avoided, but
if we wanted that, how about

      <xsl:if test="following-sibling::*[string()]">,</xsl:if>

Maybe not the most efficient, but it works.

Alternatively, we could take a substring of the $big-string
result to avoid any final comma.

Lars


 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.