Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement Carriage return in XSLT

Tags:

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

like image 615
chugh97 Avatar asked Jun 19 '09 09:06

chugh97


People also ask

How do you insert a line break in XSLT?

Include the attribute Method="text" on the xsl:output tag and include newlines in your literal content in the XSL at the appropriate points. If you prefer to keep the source code of your XSL tidy use the entity 
 where you want a new line. Show activity on this post. if you write this in file e.g.

What is text () in XSLT?

XSLT <xsl:text> The <xsl:text> element is used to write literal text to the output. Tip: This element may contain literal text, entity references, and #PCDATA.

What is current () XSLT?

XSLT current() Function The current() function returns a node-set that contains only the current node. Usually the current node and the context node are the same.

Can XSLT transform XML to CSV?

The following XSL Style Sheet (compatible with XSLT 1.0) can be used to transform the XML into CSV. It is quite generic and can easily be configured to handle different xml elements by changing the list of fields defined ar the beginning.


1 Answers

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

like image 85
Steef Avatar answered Sep 21 '22 15:09

Steef