Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Carriage return in XSL

Status
Not open for further replies.

Kenbla

Programmer
Oct 11, 2006
68
SE
Hello, I'm trying to transform an XML document to an HTML page and one of the XML tags contains a rather long text which also contains carriage return characters within the tag/text!
For example: "This text (CR)contains a long text (CR)and I want it displayed on separate lines".
I want this displayed as:
This text
contains a long text
and I want it displayed on separate lines

How do I do this in XSL?
Any help is greatly appreciated.
Regards,
Kenbla
 
[0] This may not solve every conceivable styling problem concerning the rendering of line break/wrapping. In certain case, such as text content of some div, say, using a pre tag would acheive the desired visual effect. In some case like textarea of form field, you don't need to take additional action as line break would have the desired visual effect within it...

[1] Suppose the xml tag containing the said text be "tag". The mode of template matching it would do.
[tt]
<xsl:template match="tag" mode="A">
<pre><xsl:value-of select="." /></pre>
</xsl:template>
[/tt]
[1.1] In case you are not sure on the applying templates with mode, this is an example of how it would appear.
[tt]
<xsl:apply-templates select="tag" mode="A" />
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top