What is the correct way to do an XSL Transform .Net 2.0 - XML SOAP

This is a discussion on What is the correct way to do an XSL Transform .Net 2.0 - XML SOAP ; We just switched one of our larger applications from using .Net 1.1 to .Net 2.0. The XMLDocument XMLMainDoc is used heavily in the application. One place we use it is in sending HTML emails. We transform XMLMainDoc against some XSL ...

+ Reply to Thread
Results 1 to 2 of 2

What is the correct way to do an XSL Transform .Net 2.0

  1. Default What is the correct way to do an XSL Transform .Net 2.0

    We just switched one of our larger applications from using .Net 1.1
    to .Net 2.0. The XMLDocument XMLMainDoc is used heavily in the
    application. One place we use it is in sending HTML emails. We
    transform XMLMainDoc against some XSL and send the results as an
    email. The old version of the code to get this transformed HTML as a
    string was:

    XslTransform xslt = new XslTransform();
    xslt.Load(Server.MapPath("global.xsl"));
    StringWriter MyResult = new StringWriter();
    xslt.Transform(XMLMainDoc, null, MyResult, null);
    string Result = MyResult.ToString();

    Of course though System.Xml.Xsl.XslTransform is obselete. While the
    code does compile and run just as well, is there a correct way to do
    this so that I wind up with the same Result string?

    Larry.


  2. Default Re: What is the correct way to do an XSL Transform .Net 2.0

    Larry Viezel wrote:

    > XslTransform xslt = new XslTransform();
    > xslt.Load(Server.MapPath("global.xsl"));
    > StringWriter MyResult = new StringWriter();
    > xslt.Transform(XMLMainDoc, null, MyResult, null);
    > string Result = MyResult.ToString();
    >
    > Of course though System.Xml.Xsl.XslTransform is obselete. While the
    > code does compile and run just as well, is there a correct way to do
    > this so that I wind up with the same Result string?


    You should use System.Xml.Xsl.XslCompiledTransform instead, pseudo code
    XslCompiledTransform xslt = new XslCompiledTransform();
    xslt.Load(Server.MapPath("global.xsl"));
    StringWriter myResult = new StringWriter();
    xslt.Transform(XMLMainDoc, null, myResult);
    string result = myResult.ToString();

    See
    <URL:http://msdn2.microsoft.com/en-us/library/system.xml.xsl.xslcompiledtransform.aspx>
    and <URL:http://msdn2.microsoft.com/en-us/library/66f54faw.aspx>

    --

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

+ Reply to Thread

Similar Threads

  1. Transform xml to *.txt in C# app.
    By Application Development in forum CSharp
    Replies: 3
    Last Post: 11-14-2007, 02:28 PM
  2. Need help with a transform
    By Application Development in forum XML SOAP
    Replies: 0
    Last Post: 09-13-2006, 05:58 PM
  3. XML Transform
    By Application Development in forum XML SOAP
    Replies: 0
    Last Post: 08-11-2006, 05:42 PM
  4. How to transform PDF 6.0 to PDF 4.0
    By Application Development in forum Adobe Acrobat
    Replies: 0
    Last Post: 03-31-2006, 08:36 AM
  5. Pt = transform
    By Application Development in forum Graphics
    Replies: 0
    Last Post: 12-09-2003, 02:48 AM