The "
" entity is for new-lines... but as far as I'm aware it is only for /r (not /r/n - as in Windows), although this should give you the desired result!
Remember to change the "data[@alias='bodytext']" with whatever is containing your multi-line content.
Yep, this is possible - but very flakey. The two examples above should work for most situations, but I've seen linebreaks use "
" and "
" both separately and together in the same line.
- just a quick note on linefeeds in XML: An XML parser is required to normalize linefeed/carriage-return sequences to a single linefeed character (
), before handing the document over to the receiver. So whether we're on Windows, Linux or Mac OS we should actually be able to easily recognize any newline character in content.
Convert multiple lines to unordered list
Is it possible, with XSLT, to take a number of lines in a multi-line text (Textbox Multiple) and convert each line into a <li> item?
Rumors on the web say, it is possible, but example didn't work for me, so i switched to a .net control.
Hi Gordon,
Try this XSLT:
A recursive template should do the trick (modify the param statement to select the property holding your multiline textbox):
<!-- Recursive template to write statements from a textarea property (e.g., newline-separated values) to successive <li> elements --> <xsl:template name="output-statements"> <xsl:param name="statements" select="data[@alias = 'statements']" /> <xsl:if test="contains($statements, '
')"> <li> <xsl:value-of select="substring-before($statements, '
')" /> </li> <xsl:call-template name="output-statements"> <xsl:with-param name="statements" select="substring-after($statements, '
')" /> </xsl:call-template> </xsl:if> <xsl:if test="normalize-space($statements)"> <li> <xsl:value-of select="$statements" /> </li> </xsl:if> </xsl:template>
You execute it with the call-template instruction from:
/Chriztian
Yep, this is possible - but very flakey. The two examples above should work for most situations, but I've seen linebreaks use "
" and "
" both separately and together in the same line.
It's important to remember that the chars for linebreaks will differ between OS' -> http://www.osix.net/modules/article/?id=93
Here's another (!) alternative solution, for text entered on a windows machine
Dan
Thanks Lee, that worked perfectly :-)
- just a quick note on linefeeds in XML: An XML parser is required to normalize linefeed/carriage-return sequences to a single linefeed character (
), before handing the document over to the receiver. So whether we're on Windows, Linux or Mac OS we should actually be able to easily recognize any newline character in content.
(http://www.w3.org/TR/REC-xml/#sec-line-ends)
/Chriztian
Another alternative, not sure on relative speeds... this one using regexp...
<xsl:template match="/">
<ul>
<li>
<xsl:value-of disable-output-escaping="yes" select="Exslt.ExsltRegularExpressions:replace($currentPage/*[name() = $property], '(
)+', 'Gi', '</li><li>')"/>
</li>
</ul>
</xsl:template>
is working on a reply...