简体   繁体   English

怎么把VS2003的XslTransform转换成VS2005的XslCompiledTransform?

[英]How to convert from XslTransform of VS2003 to XslCompiledTransform of VS2005?

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 . 目前,我们正在将我们的项目从VS2003转换为VS2005 ,我正在寻找正确的方法,以使用XslTransform将代码XslTransformXslCompiledTransform

The changing the class name is not the big deal, but when it comes to using XslCompiledTransform's Transform method, I have a problem. 更改类名并不重要,但是在使用XslCompiledTransform's Transform方法时,我遇到了问题。

Before XslTransform's Transform method was accepting XPathDocument object and right now Transfrom method expect XmlReader instead: XslTransform's Transform方法接受XPathDocument对象之前,现在Transfrom方法期望使用XmlReader代替:

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 . 另外,新的Transform方法期望使用System.Xml.XmlWriter而不是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. 以下链接描述了XslCompiledTransform和XslTransform类之间的区别。

A section has also some code samples in both versions. 一个部分还提供了两个版本中的一些代码示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM