【发布时间】:2020-12-03 07:22:17
【问题描述】:
我有一个 .Net Core 3.1 应用程序和一个 XSLT 2.0 脚本。该脚本现在应该由应用程序执行。
首先我尝试过:
//Create a new XslCompiledTransform and load the compiled transformation.
XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load(typeof(Transform));
// Execute the transformation and output the results to a file.
xslt.Transform("books.xml", "discount_books.html");
但这似乎只适用于 .net 框架并且仅适用于 XSLT 1.0。
不,我找到了 Nuget-Package Saxon-HE-fixedrefs,根据描述,它应该与 .net 核心兼容。但是在编译时,我的第一行出现错误
Saxon.Api.Processor proc = new Saxon.Api.Processor();
"System.TypeInitializationException: "'net.sf.saxon.Configuration' 的类型初始化器抛出异常。"
FileNotFoundException:无法加载文件或程序集“System.Configuration.ConfigurationManager,Version=4.0.3.0,Culture=neutral,PublicKeyToken=cc7b13ffcd2ddd51”。 "
有什么解决方法吗?
【问题讨论】:
-
请参阅stackoverflow.com/a/58931196/252228 以获取 XmlPrime 选项,至少在技术上,您需要与他们联系以了解许可或未来版本。至于 Saxon,我不知道该 fixedrefs 项目试图修复什么,但我的理解是 .NET 上的 Saxon 依赖于为 .NET 框架开发的 IKVM,与 .NET 核心不兼容。当然,在 ASP.NET 中,应该可以编写一个 ASP.NET 框架 Web API,您的 ASP.NET Core 页面可以像使用另一个 REST API 一样使用它。
-
Saxon-HE-fixedrefs 最后一次发布是在 2016 年,据说可以与“.NET Core CLI 工具 1.0.0-preview2”一起使用。为什么您希望它在 4 年后与当前版本的 .NET Core 一起使用?
标签: c# asp.net-core xslt saxon