![]() |
|
|
|
| ||||||
|
Welcome to the The ProgrammersTalk Community forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| Tags: |
![]() |
![]() | | LinkBack | Thread Tools | Display Modes | ![]() |
| |||
| [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> |
| |
| |||
| you always have to think differently with xsl! perhaps you need to have the resultant tree be <tag1> with the text of every subnode separated by a comma... in that case the code is much simpler. are you in the biz or learning in school? have you made any attempts? post what you have tried. here's a hint! <onetag> <xsl:for-each select="manytags"> <xsl:value-of select="."/> <xsl:if test="position()!=last()">,</xsl:if> </xsl:for-each> </onetag> does that help? |
![]() |
| Thread Tools | |
| Display Modes | |
| |