XSLT comma separation of elements

AliceC

New Member
I have the following XML document:\[code\]<?xml version="1.0" encoding="UTF-8"?><cars> <car> <entrydata columnnumber="4" name="Colour"> <text>Red</text> </entrydata> </car> <car> <entrydata columnnumber="4" name="Colour"> <textlist> <text>Yellow</text> <text>Blue</text> </textlist> </entrydata> </car></cars>\[/code\]And the following XSLT stylesheet:\[code\]<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com: xslt" exclude-result-prefixes="msxsl"> <xsl:output method="xml" indent="yes"/> <xsl:template match="/"> <records> <xsl:apply-templates select="//cars"/> </records> </xsl:template> <!--Top level template --> <xsl:template match="cars"> <!-- Loop through each document (viewentry) and apply create the rows for each one--> <xsl:for-each select="car"> <record> <xsl:attribute name="Colour"> <xsl:value-of select="entrydata[@name='Colour']"/> </xsl:attribute> </record> </xsl:for-each> </xsl:template></xsl:stylesheet>\[/code\]This produces the following output:\[code\]<?xml version="1.0" encoding="UTF-8"?><records> <record Colour="Red"/> <record Colour="YellowBlue"/></records>\[/code\]How would I modify the XSLT file so that the output becomes (note the comma separation of \[code\]<textlist>\[/code\]):\[code\]<?xml version="1.0" encoding="UTF-8"?><records> <record Colour="Red"/> <record Colour="Yellow, Blue"/></records>\[/code\]
 
Back
Top