View Single Post
  #1 (permalink)  
Old 06-10-2007, 05:25 PM
stevenjj2002
Posts: n/a
[SOLVED] XSLT: how do I compbine multiple nodes into 1 node?

Here is my heirarchy...

<Tag0>
<Tag1>
<Tag2>Data</Tag2>
</Tag1>
<Tag1>
<Tag2>Data</Tag2>
</Tag1>
<Tag1>
<Tag2>Data</Tag2>
</Tag1>
</Tag0>

I need the Data combined under Tag1 separated by a comma like this...

<Tag0>
<Tag1>Data, Data, Data<Tag1>
<Tag0>
Here are some
I'm in the biz, but still learning.

Here is what I have now.
<xsl:template match="Tag1">
<xsl:copy>
<xsl:for-each select="Tag2">
<xsl:apply-templates select="."/>
<xsl:text>, </xsl:text>
</xsl:for-each>
</xsl:copy>
</xsl:template>

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

From the example in the initial question, this give me...

<Tag0>
<Tag1>Data, </Tag1>
<Tag1>Data, </Tag1>
<Tag1>Data, </Tag1>
</Tag0>

I need it to be...

<Tag0>
<Tag1>Data, Data, Data</Tag1>
</Tag0>

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!