C# 的 XSLT 2.0 版本转换问题
您好,我有几个 XSLT 2.0 文件。我需要用 C# 来转换这些.. 我使用从该网站获得的以下代码:http://www.csharpfriends。 com/Articles/getArticle.aspx?articleID=63
public bool Transform(string XMLPath, string XSLPath, string newXMLname){
try{
XPathDocument myXMLPath = new XPathDocument(XMLPath); //load the Xml doc
XslCompiledTransform myXSLTrans = new XslCompiledTransform();
myXSLTrans.Load(XSLPath); //load the Xsl
XmlTextWriter myWriter = new XmlTextWriter(newXMLname, null); //create the output stream
myXSLTrans.Transform(myXMLPath, null, myWriter); //do the actual transform of Xml ---> fout!!??
myWriter.Close() ;
return true;
}catch(Exception e){
return false;
}
}
但它不起作用..我认为这是因为我使用 XSLT 版本 2.0。 有代码/方法可以做到这一点吗?因为无法将我的 XSLT 文件更改为版本 1.0...
提前致谢!
Hi I've got several XSLT 2.0 files. I need to transform these with C#..
I use the following code I got from this site: http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=63
public bool Transform(string XMLPath, string XSLPath, string newXMLname){
try{
XPathDocument myXMLPath = new XPathDocument(XMLPath); //load the Xml doc
XslCompiledTransform myXSLTrans = new XslCompiledTransform();
myXSLTrans.Load(XSLPath); //load the Xsl
XmlTextWriter myWriter = new XmlTextWriter(newXMLname, null); //create the output stream
myXSLTrans.Transform(myXMLPath, null, myWriter); //do the actual transform of Xml ---> fout!!??
myWriter.Close() ;
return true;
}catch(Exception e){
return false;
}
}
But it doesn't work.. I think it's because I use XSLT version 2.0.
Is there a code/way to do this? Because there is no way to change my XSLT files to version 1.0...
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
设计用于在 .NET 环境中工作的两个 XSLT 2.0 处理器是 Saxon.NET 和 XQSharp。
作为 .NET 一部分的 XslCompiledTransform 和 XslTransform 处理器仅实现 XSLT 1.0。
The two XSLT 2.0 processors that are designed to work in the .NET environment are Saxon.NET and XQSharp.
The XslCompiledTransform and XslTransform processors that come as part of .NET only implement XSLT 1.0.
.Net Framework 本身不支持 XSLT 2.0。我建议使用 XSLT 1.0,但如果不能,请使用第三方组件,例如 Saxon 。
Natively .Net Framework doesn't support XSLT 2.0. I would suggest to use XSLT 1.0, but if you can't, then use third party component, for example Saxon.