[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] New Line using XSLT


Subject: Re: [xsl] New Line using XSLT
From: "Heiko Niemann kontakt@xxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 2 Mar 2016 10:26:37 -0000

Hi,

when outputting text with new line(s) I favor using a value-of element
plus seperator with any number of nested sequence elements. For 'new line'
as seperator I prefer using codepoints-to-string(10), which worked for me
as the most reliable way. I bet there are pros and cons, but at the moment
this works best for me and seems to be the most flexible.

Sample:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
  <xsl:output method="text"/>
  <xsl:template match="/">
    <xsl:value-of separator="{codepoints-to-string(10)}">
      <xsl:for-each select="1 to 10">
        <xsl:sequence select="."/>
      </xsl:for-each>
    </xsl:value-of>
  </xsl:template>
</xsl:stylesheet>

One con would be that this reqires XSLT 2.0/XPath 2.0.


Heiko




> Hi,
>
> I want to generate a "text" file in which every row should be in separate
> line.
> I have use "&#x0A;,&#x0D;" and <xsl:text>
> </xsl:text>
>
> But all the above seems not to work.
>
> Please suggest.
>
> --
> Vishnu Singh | http://marklogicgd.blogspot.in/


Current Thread
Keywords