[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: New line characters to </br> element.
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
|
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
|