Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - For Each to a Comma Separated List >Thread Next - Re: For Each to a Comma Separated List Re: For Each to a Comma Separated ListTo: NULL Date: 10/22/2009 12:02:00 PM Brian wrote: > Here is the simple XML Block where I want to transform the ListNode items > into a comma separated list that gets inserted into a table cell. > > <XMLBlk BlkAttr="A001"> > <NodeA>Standard</NodeA> > <ListNode> > <ListItem>Item 1</ListItem> > <ListItem>Item 2</ListItem> > <ListItem>Item 3</ListItem> > </ListNode> > <AnotherNode></AnotherNode> > </XMLBlk> > > The list output would be "Item 1, Item 2, Item 3" With XSLT 2.0 creating the comma separated list is as easy as <xsl:template match="ListNode"> <xsl:value-of select="ListItem" separator=", "/> </xsl:template> With XSLT 1.0 you need <xsl:template match="ListNode"> <xsl:for-each select="ListItem"> <xsl:value-of select="."/> <xsl:if test="position() != last()">, </xsl:if> </xsl:for-each> </xsl:template> > My table is somehow creates the CSL but inserts the individual items into > what appears to be sub-cells. I get word wrapping on the "Item 1" text > before it writes the "Item 2" text in the table cell. > > Question... what is the best way to structure this transform so that the > cell just gets a CSL and wraps the content if it exceeds the width of the > table cell? What kind of output do you create with the XSLT? Is that HTML? -- Martin Honnen --- MVP XML http://msmvps.com/blogs/martin_honnen/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
