tags:

views:

3298

answers:

4

I want to implement carriage return within xslt. The problem is I have a varible: Step 1 = Value 1 breaktag Step 2 = Value 2 as a string and would like to appear as

Step 1 = Value 1

Step 2 = Value 2

in the HTML form but I am getting the br tag on the page.Any good ways of implementing a line feed/carriage return in xsl would be appreciated

+1  A: 

use a simple carriage return in a xsl:text element

<xsl:text>
</xsl:text>
Pierre
and that is pretty annoying, when you've indented all your XML nicely, then you have to put this...
streetpc
The string is held in the db and i tried adding <xsl:text></xsl:text> but its printing the tag instead of getting a line break.
chugh97
A: 

I believe that you can use the xsl:text tag for this, as in

<xsl:text>
</xsl:text>

Chances are that by putting the closing tag on a line of its own, the newline is part of the literal text and outputted as such.

Frerich Raabe
The string is held in the db and i tried adding <xsl:text></xsl:text> but its printing the tag instead of getting a line break.
chugh97
+8  A: 

As an alternative to

<xsl:text>
</xsl:text>

you could use

<xsl:text>&#10;</xsl:text> <!-- newline character -->

or

<xsl:text>&#13;</xsl:text> <!-- carriage return character -->

in case you don't want to mess up your indentation

Steef
My string is in the database A<xsl:text/>B<xsl:text> and when rendered it displays as is and not a line break...tried does not work.Works when hardcoded in xsl file but my values comes from db.
chugh97
I think some more information is needed to find a solution to your problem. Could you describe in more detail how you are getting the string from the database and how you are applying the XSL? What is the format of the string in the database? Is it plain text? XML?
Steef
+1  A: 

I separated the values by Environment.NewLine and then used a pre tag in html to emulate the effect I was looking for

chugh97