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 / August 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Larry  Viezel - 27 Aug 2007 23:21 GMT
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.
Martin Honnen - 28 Aug 2007 11:52 GMT
Larry Viezel wrote:

> XslTransform xslt = new XslTransform();
> xslt.Load(Server.MapPath("global.xsl"));
[quoted text clipped - 5 lines]
> 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>

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.