Fishcake
Fishcake

Reputation: 10774

Explicitly specify linefeed character and not carriage return

I'm having trouble generating text files in the format required by a clients interface. The clients requires Linefeed characters at the end of every line in the file.

I'm using Microsoft XSLT processor and seem unable to specify a linefeed character. Here's some examples I've created trying to address the issue.

XSLT

<xsl:output method="text"/>

<xsl:template match="/">
    <xsl:text>LINEFEED</xsl:text>
    <xsl:text>&#xA;</xsl:text>
    <xsl:text>CARRIAGE RETURN</xsl:text>
    <xsl:text>&#xD;</xsl:text>
    <xsl:text>LINEFEED + CARRIAGE RETURN</xsl:text>
    <xsl:text>&#xA;&#xD;</xsl:text>
</xsl:template>

Output

EFBB BF4C 494E 4546 4545 4420 7841 0D0A 4341 5252 4941 4745 2052 4554 5552 4E20 7844 0D0A 4C49 4E45 4645 4544 202B 2043 4152 5249 4147 4520 5245 5455 524E 0D0A 0D0A

At present I am unable to find a way of explicitly just outputting a linefeed character (0A).

Any help greatly appreciated.

Upvotes: 2

Views: 1471

Answers (1)

Dimitre Novatchev
Dimitre Novatchev

Reputation: 243529

In case you are using .NET XslCompiledTransform you can use an XmlWriter and specify the XmlWriterSettings.NewLineChars Property in the desired way.

Upvotes: 1

Related Questions