I want to produce a newline for text output in XSLT. Any ideas?
Thanks
I want to produce a newline for text output in XSLT. Any ideas?
Thanks
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.
My favoured method for doing this looks something like:
<xsl:stylesheet>
<xsl:output method='text'/>
<xsl:variable name='newline'><xsl:text>
</xsl:text></xsl:variable>
<!-- note that the layout there is deliberate -->
...
</xsl:stylesheet>
Then, whenever you want to output a newline (perhaps in csv) you can output something like:
<xsl:value-of select="elem1,elem2,elem3,$newline") />
I've used this technique when outputting sql from xml input. In fact, I tend to create variables for commas, quotes and newlines.
You can use:
<xsl:text>
</xsl:text>
I used this type of writing code to insert and use xslt in sql server tables, and works ... .