Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / February 2008

Tip: Looking for answers? Try searching our database.

now to set line endings with XSLT

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andy Fish - 26 Feb 2008 15:07 GMT
Hi,

I am using .Net 2.0 XslCompiledTransform with output method=text.

it seems to be converting all the line endings in the output to cr/lf
regardless of how I generate them. for instance, this fragment

<xsl:text>|&#xd;|&#xd;&#xa;|&#xa;|<xsl:text>

generates |<crlf>|<crlf>|<crlf>|

any idea how I can control the line endings generated by the XSLT processor?

TIA

Andy
Martin Honnen - 26 Feb 2008 16:02 GMT
> any idea how I can control the line endings generated by the XSLT
> processor?

I am not sure there is a way other than post-processing the result of
the XSLT transformation.

Signature

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/

Andy Fish - 28 Feb 2008 12:51 GMT
FWIW I found out you can do it using XmlWriterSettings.NewLineChars or
XmlWriterSettings.NewLineHandling. here's a sample:

XslCompiledTransform trans = new XslCompiledTransform();
trans.Load(...);
XmlWriterSettings ws = trans.OutputSettings.Clone();
ws.NewLineChars = '\n';
using (XmlWriter xw = XmlWriter.Create(..., ws))
{
   trans.Transform(..., xw);
}

Andy

>> any idea how I can control the line endings generated by the XSLT
>> processor?
>
> I am not sure there is a way other than post-processing the result of the
> XSLT transformation.
Martin Honnen - 28 Feb 2008 13:38 GMT
> FWIW I found out you can do it using XmlWriterSettings.NewLineChars or
> XmlWriterSettings.NewLineHandling. here's a sample:
[quoted text clipped - 3 lines]
> XmlWriterSettings ws = trans.OutputSettings.Clone();
> ws.NewLineChars = '\n';

Nice. I tried settings NewLineChars too but did not clone it and then
the properties were read-only and my attempts failed.

Signature

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.