Sunday, February 9, 2020

XSLT with carriage returns and line breaks

I needed to translate carriage returns and line feeds to <BR/> elements in an XSLT process.  Sometimes you get hung up how you normally use functions and then hit a language wall that you think should work,

In this case, the solution was to iterate over the selection and output the elements with an appended tag.

<tr><td><xsl:for-each select="tokenize(customerinfo/@comments, '&#xD;&#xA;')">
                <xsl:value-of select="." /><br/>
</xsl:for-each></td></tr>