|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Convert newlines to <BR/>
I should have been a Lisp programmer -- every problem I'm having needs
recursion to fix it. Thanks for the solution.
Here's an extension function for the same thing:
----------------------------------------------------------------------------
----------------------
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:CRLF="http://www.jclark.com/xt/java/net.px.extension.CRLF">
<xsl:value-of disable-output-escaping="yes"
select="CRLF:replace(string(.))"/>
package net.px.extension;
public class CRLF {
public static String replace(String line) {
StringBuffer sb = new StringBuffer(line.length() + 50);
int i = 0;
int k = 0;
int cr = 13;
while (k != -1) {
k = line.indexOf(cr, i);
if (k != -1) {
sb.append(line.substring(i, k - 1));
sb.append("<br/>");
} else
sb.append(line.substring(i));
i = k + 1;
}
return sb.toString();
}
}
Jon Smirl
jonsmirl@xxxxxxxxxxxx
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








