Click to See Complete Forum and Search --> : xsl:apply-templates - help needed


Avinash Salimat
November 13th, 2003, 12:01 AM
Dear all
Please help me imme in solving this.
I have some thing like this -
<tag1>
........
........
<childtag1>ChildValue1</childtag1>
<childtag1>ChildValue2</childtag1>
<childtag1>ChildValue3</childtag1>
.......
</tag1>

In the XSL, Iam using
<xsl:template match='tag1'>
<test1><xsl:apply-templates select="childtag1"></test1>
</xsl:template>

The <xsl:apply-templates> element applies a template rule to the current

element or to the current element's child nodes.
So the output value (in the output xml) Iam getting is -
<test1>ChildValue1ChildValue2ChildValue3</test1>
I want this output to be separated by commas, like
<test1>ChildValue1, ChildValue2, ChildValue3</test1>.

How to achieve this?
Thx in advance.

-Avinash


***********************************

khp
November 13th, 2003, 11:20 AM
You could change your template for tag1 to something like this

<xsl:template match='tag1'>
<test1>
<xsl:for-each select="childtag1">
<xsl:if test="preceding-sibling::childtag1">
<xsl:text>,</xsl:text>
</xsl:if>
<xsl:apply-templates select="."/>
</xsl:for-each>
</test1>
</xsl:template>

Avinash Salimat
November 13th, 2003, 09:45 PM
Thanks a lot, khp, its working using for-each.