Line breaks in long text fields

Sep 28, 2010 at 2:50 PM

This is basically a text-replace function...

<xsl:template name="add-line-breaks">
   <xsl:param name="string"/>
      <xsl:when test="contains($string, '&#xA;')">
         <xsl:value-of select="substring-before($string, '&#xA;')" disable-output-escaping="yes"/>
         <br />
         <xsl:call-template name="add-line-breaks">
            <xsl:with-param name="string"
                            select="substring-after($string, '&#xA;')" />
         <xsl:value-of select="$string" disable-output-escaping="yes" />


Sep 29, 2010 at 1:17 AM


Can you explain a bit how you used this template? I can see how it works, but I'm struggling a little with the use case.

Thanks a lot for pitching it into the project!


Sep 29, 2010 at 8:47 AM

Hi Marc,

Simple. When you have a List with a field that is "Multiple lines of text" and is set to Plain Text, there is no HTML encoding in the text that's saved. This template restores the line breaks when the field is shown in a DVWP.