We are currently converting our project from VS2003
to VS2005
and I'm looking for the right way to convert the code using XslTransform
to XslCompiledTransform
.
The changing the class name is not the big deal, but when it comes to using
XslCompiledTransform's
Transform method, I have a problem.
Before XslTransform's
Transform method was accepting XPathDocument
object and right now Transfrom
method expect XmlReader
instead:
Here is the code:
XslCompiledTransform xslt = new XslCompiledTransform();
XPathDocument doc = new XPathDocument(new StringReader(DS.GetXml().ToString()));
StringWriter sw = new StringWriter();
xslt.Transform(doc,null,sw,null);
Also, new Transform
method expect System.Xml.XmlWriter
instead of System.IO.StringWriter
.
What is the best way to fix that?
Thank you
The following link describes the differences between the XslCompiledTransform and the XslTransform classes.
A section has also some code samples in both versions.