I transform an XML file to HTML via XSL.
In my html-table I have a column where I need to break the cell’s content to a new line for each entry in one of my xml element-tags.
I’m not sure how to set up the xml-file for this.
Here’s the output I was thinking of for my html-file:
<info>
line1<br/>
line2<br/>
line3<br/>
line4
</info>
and what doesn’t work for me on the xsl-part:
<td>
<xsl:for-each select="info">
<xsl:value-of select="." /> <br/>
</xsl:for-each>
</td>
I’ve tried wrapping the lines in the xml with <ul> and <li> but that didn’t work. I think it’s the xsl-part where I have the error. If I put a <br/> after the value-of statement it will output everything and then add the <br/> but of course I want the <br/> for each entry.
I hope you can tell me of a way how to set this up correctly.
This transformation:
when applied on the following XML document (as no source XML document is provided in the question):
produces the wanted result (
<info>intentionally not generated as this isn’t an HTML element):Note 1: This transformation was verified to produce exactly the above result with all of my XSLT 1.0 and 2.0 processors: MSXML3, MSXML4, MSXML6, .NET XslCompiledTransform, .NET XslTransform, Saxon 6.5.4, XML-SPY, Saxon 9.1.05, XQSharp, AltovaXML2011 (XML-SPY for XSLT 2.0).
Note 2: If you really want to have the result wrapped int an
<info>element, just add this template: