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

Re: Question reqarding display the content pending on

Subject: Re: Question reqarding display the content pending on the number of elements
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Wed, 23 Jan 2002 16:38:39 +0000
adding a comma to xsl
Hi Kit,

> the question is, how do i insert the comma at the end of each
> children element using xsl stylesheet BUT not adding a comma for the
> last children (e.g. wayne for the smith and Jay)?

Iterate over the children elements, and add a comma for each of them,
unless they are the last, which you can work out by looking at their

  <xsl:for-each select="children">
    <xsl:value-of select="." />
    <xsl:if test="position() != last()">, </xsl:if>

[Or in XSLT 2.0, simply:
 <xsl:value-of select="children" separator=", " />]

> in addition, is there a way to use xsl:if statment that will give a
> condition that states "if the number of element (children in the
> above example) are more than 1"


  <xsl:if test="count(children) > 1">...</xsl:if>

Or if you prefer, you can just test whether there's a second children

  <xsl:if test="children[2]">...</xsl:if>



Jeni Tennison

 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.