Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6471485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:13:46+00:00 2026-05-25T06:13:46+00:00

Using Vs 2010 I am editing a xsl file which will be used for

  • 0

Using Vs 2010 I am editing a xsl file which will be used for transformation to output an xml file. I am trying to output a carriage return ( ) and that only. I don’t want the linefeed character (x0A) to appear.

No matter what kind of stunt I do in the xsl, the outputted file always adds a LF to my CR (CRLF) and I don’t want that. The reason for why I want only the CR is that the output is parsed by a secondary system that sends sms-messages, which requires only LF.

I’m wondering if the problem is in the xsl or the transformation process.

The stylesheet:

<xsl:stylesheet xmlns:l="http://schemas.something.no/2008/" version='1.0'>
 <xsl:import href='LydiaDateFuncs.xsl'/>
 <xsl:template match='/'>
   <xsl:apply-imports/>
 </xsl:template>
 <xsl:output method="xml" encoding="utf-8" indent="no" />

 <xsl:template match="l:WorkOrderOccurrenceBE">
   <Message>
     <Body>
       Adding cr here<xsl:text>&#xD;</xsl:text><xsl:text>&#xD;</xsl:text>No dice.
     </Body>
   </Message>
 </xsl:template>

The code for transformation:

public static XmlDocument TransformObject(string xslFilepath, object serObj) 
{
XmlDocument result = null;
xslTransf.Load(xslFilepath, new XsltSettings { EnableScript = true }, newXmlUrlResolver());
result = TransformObject(xslTransf, serObj);
}

public static XmlDocument TransformObject(XslCompiledTransform xslTransform, object transformObject)
{
    XmlDocument result = null;
    if (xslTransform != null)
    {
        DataContractSerializer serializer = new DataContractSerializer(transformObject.GetType());

        string serializedObjValue = null;
        using (MemoryStream stream = new MemoryStream())
        {
            serializer.WriteObject(stream, transformObject);
            serializedObjValue = (new UTF8Encoding()).GetString(stream.ToArray());
        }

        if (serializedObjValue != null)
        {
            XmlDocument xmldoc = new XmlDocument();
            xmldoc.LoadXml(serializedObjValue);

            XmlDeclaration xmldec = xmldoc.CreateXmlDeclaration("1.0", "utf-8", null);
            xmldoc.InsertBefore(xmldec, xmldoc.DocumentElement);

            using (Stream stream = new MemoryStream())
            {
                xslTransform.Transform(xmldoc, null, stream);
                stream.Position = 0;
                using (StreamReader sr = new StreamReader(stream, Encoding.Unicode))
                {
                    string xmlRes = sr.ReadToEnd();
                    result = new XmlDocument();
                    result.LoadXml(xmlRes);
                }
            } 
        }  
    }
    return result;
}

Anybody been experiencing a similar issue?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:13:46+00:00Added an answer on May 25, 2026 at 6:13 am

    One way to solve this problem is to use an XmlTextWriter in a respective overload of XslCompiledTransform.Transform()

    This instnce of XmlTextWriter must have its Settings property set with an instance of XmlWriterSettings for which you have specified whatever newline characters you want as the value of the XmlWriterSettings.NewLineChars property.

    See: http://msdn.microsoft.com/en-us/library/system.xml.xmlwriter.settings.aspx

    and

    http://msdn.microsoft.com/en-us/library/system.xml.xmlwritersettings.newlinechars.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a TFS 2010 server plugin that updates a field in a work
I'm new to using the C#/.NET programming Language and I have created a DataGridView
I've followed Steve Sanderson’s Editing a variable length list, ASP.NET MVC 2-style guide and
At first I should mention that this problem only occurs in windows forms applications
I've been fiddling with setting up automated builds for our old VB6 COM components.
Possible Duplicates: What Are Some Good .NET Profilers? Any decent C# profilers out there?
I have a problem with IIS Express & it's annoying the hell out of
In my page in edit mode, when i select the Media Web Part, in
Following is our setup & requirement: There's a public web application accessible via SSL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.