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

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

Subject: Re: How to use for-each to get comma searated list?
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 02 Dec 1998 16:23:22 -0500
comma after list
At 98/12/02 14:43 -0500, I wrote:
>At 98/12/02 12:43 -0500, Farrukh S. Najmi wrote:
>>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. 
>I can almost get you there, but I don't understand why
>IE5.0beta2(5.00.0910.1309) isn't completing the job for me.  I'll still
>work on it, but I thought I'd post these intermediate results in case
>someone sees what I'm doing wrong.  The script below will display the
>correct number of commas, but not the values!

Okay, I found the use of the "textnode()" function, so the following XML
file "test3.xml" and XSL script "test.xsl" successfully produce a comma
separated list.

<?xml version="1.0"?>
<?xml-stylesheet href="test.xsl" type="text/xsl"?>


<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">

<xsl:template match="/">

<xsl:template match="/Doc">     <!-- first prepare commentary around list -->
       valueList="<xsl:apply-templates select="Section"/>"

                 <!-- when more than one in list, punctuation after others -->
<xsl:template match="Section">

              <!-- no punctuation after last (same as if only one in list) -->
<xsl:template match="Section[end()]">

<xsl:template match="Foo"><xsl:apply-templates/></xsl:template>

<xsl:template match="Value">

<xsl:template match="textnode()">
  <xsl:get-value/></xsl:template> <!-- nl after get-value produces space -->


G. Ken Holman         mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.  http://www.CraneSoftwrights.com/s/
Box 266,                                V: +1(613)489-0999
Kars, Ontario CANADA K0A-2E0            F: +1(613)489-0995
Training:   http://www.CraneSoftwrights.com/s/schedule.htm
Resources: http://www.CraneSoftwrights.com/s/resources.htm
Shareware: http://www.CraneSoftwrights.com/s/shareware.htm

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

Current Thread


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.
First Name
Last Name
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.