Subject: Re: [xsl] New line characters to </br> element. From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Sun, 4 Mar 2001 18:28:59 +0000 |
Hi Jakub, > I have problem with displaying of text, which contain new line > characters, when I transcode XSL to HTML. I guess that it is more > problem of HTM than of XSL. So, HTML cuts these characters and > represent theme as a space. But, I think, that there could by some > way how to translate newline characters to for example </br> > element. Is there any way? Or, does anybody know any other solution? You could try using the CSS 'white-space' property set to 'pre', e.g.: <p style="white-space: pre;"> ... </p> but you might not get much joy because browsers can legally ignore the property. The other option is to replace all the line breaks (i.e. 
 characters) in the text with 'br' elements) using a recursive named template like: <xsl:template name="add-line-breaks"> <xsl:param name="string" select="." /> <xsl:choose> <xsl:when test="contains($string, '
')"> <xsl:value-of select="substring-before($string, '
')" /> <br /> <xsl:call-template name="add-line-breaks"> <xsl:with-param name="string" select="substring-after($string, '
')" /> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$string" /> </xsl:otherwise> </xsl:choose> </xsl:template> You can call this template as appropriate with the $string parameter being passed the value of the string that you want to perform the replacement on. I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] New line characters to </br> , Jakub Maly | Thread | RE: [xsl] New line characters to </, Manjul Sahay |
Re: [xsl] cocoon and entities probl, Jeni Tennison | Date | RE: [xsl] xslt, script, attribute a, Chris Bayes |
Month |