[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Convert newlines to <BR/>

Subject: Re: Convert newlines to <BR/>
From: "Jon Smirl" <jonsmirl@xxxxxxxxxxxx>
Date: Wed, 29 Dec 1999 11:14:45 -0500
convert crlf 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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.