How to use for-each to get comma searated list?

Subject: How to use for-each to get comma searated list?
From: "Farrukh S. Najmi" <najmi@xxxxxxxxx>
Date: Wed, 02 Dec 1998 12:43:30 -0500
I am trying to use the current version of XSL (ala IE5.0 beta2) to
format the values inside a XML element into a comma separated list. The
problem is that I cannot figure out how to not have a comma after the
last element in the list. Any help would be appreciated. Following is
simplified XML file, desired output and my attempt at the XSL file:

-------------
#Following is a simplified XML file

<Doc>
  <Section>
    <Foo><Value>3.75</Value></Foo>
  </Section>

  <Section>
    <Foo><Value>2.25</Value></Foo>
  </Section>
</Doc>

--------------
#Following is a simplified target HTML mapping desired

<BODY>valueList="3.75,2.25"</BODY>

--------------

#Following is my simplified XSL file

<xsl:template match="/">
<BODY>
       <xsl:text>valueList="</xsl:text>
       <xsl:for-each select="Section/Foo">
          <xsl:process select="Value"/>
          <xsl:text>,</xsl:text>
       </xsl:for-each> 
       <xsl:text>"</xsl:text>
</BODY>
</xsl:template> 

-- 

Regards,
Farrukh Najmi


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


Current Thread