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

Re: newline [\n] to <br />

Subject: Re: newline [\n] to <br />
From: "scott" <scott@xxxxxxxxxxxxxxxx>
Date: Fri, 24 Oct 2003 01:06:17 +0100
xsl newline
Duh...i got it :)

<xsl:call-template name="break">
<xsl:with-param name="text">
<xsl:value-of select="body"/>
</xsl:with-param>
</xsl:call-template>

The faq needs to be a bit clearer for idiots like me ....

What the heck is :

<xsl:template match="text()">
   <xsl:call-template name="break">
</xsl:template>

That about then??? Still after recommendations for books though please.


-----Original Message-----
From: scott [mailto:scott@xxxxxxxxxxxxxxxx] 
Sent: 23 October 2003 23:51
To: 'XSL-List@xxxxxxxxxxxxxxxxxxxxxx'
Subject: newline [\n] to <br />

Im very new to this, so apologies for what I know must be a dumb question,
but i can't find anything solid anywhere; I've looked at the faq but I cant
get it working.

I need to replace \n newlines in some output from a MySQL db - ive tried
doing this in php (wrong idea I guess) before passing to the parser, but
that doesn't work. So I find this:

code from faq [replace]...

<xsl:template match="text()">
   <xsl:call-template name="break">
</xsl:template>

<xsl:template name="break">
   <xsl:param name="text" select="."/>
   <xsl:choose>
   <xsl:when test="contains($text, '&#xa;')">
      <xsl:value-of select="substring-before($text, '&#xa;')"/>
      <br/>
      <xsl:call-template name="break">
          <xsl:with-param name="text" select="substring-after($text,
'&#xa;')"/>
      </xsl:call-template>
   </xsl:when>
   <xsl:otherwise>
	<xsl:value-of select="$text"/>
   </xsl:otherwise>
   </xsl:choose>
</xsl:template>

my (simple!) stylesheet ...

<xsl:template match="/">
/* more html / xsl:value-of's here...
<p>
<xsl:value-of select="body"/>
</p>
<xsl:if test="links">
<ul>
<xsl:for-each select="links/url">
<li>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="location"/>
</xsl:attribute>
<xsl:value-of select="text"/>
</xsl:element>&nbsp;<xsl:value-of select="comment"/>
</li>
</xsl:for-each>
</ul>
</xsl:if>
/* more html / xsl:value-of's here...
</xsl:template>


this ::  <xsl:value-of select="body"/> :: is what I want to parse for
newlines and replace with html breaks on output(outputting to xhtml); ive
tried dropping the template in to replace the above line, using part of it
(the choose etc), adding the template outside the existing one.... I can't
get it to work, and I cant find any info on the web that isn't either
completely basic, or over my head at this stage.
Please, how do I USE this template with regards to an existing one??
Any recommendations for books would be appreciated too.

thanks

scott mathieson 



 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.