简体   繁体   English

ASP CORE中的XslCompiledTransform

[英]XslCompiledTransform in ASP CORE

I'm trying implement XslCompiledTransform in asp core, after reading in many forums and documentation, think XslCompiledTransform is not supported for now, has someone been able to implement XslCompiledTransform in asp core? 我正在尝试在asp核心中实现XslCompiledTransform ,在阅读了许多论坛和文档后,认为现在不支持XslCompiledTransform ,有人能够在asp核心中实现XslCompiledTransform吗? Or do you knows of another (maybe nuget) package that can do the same thing? 或者你知道另一个(也许是nuget)包可以做同样的事情吗?

Regards 问候

I don't think anyone has, since XSLT was abandoned (and v2 was never finished) in favor of Razor. 我认为没有人,因为XSLT被放弃了(并且v2从未完成)而支持Razor。

Our company had an implementation of XSLT to be able to generate very dynamic pages. 我们公司有一个XSLT实现,可以生成非常动态的页面。 But development was just too cumbersome so we decided to move to Razor instead. 但是开发过于繁琐,所以我们决定转而使用Razor。 To this day im happy about this decision. 直到今天我对这个决定感到高兴。

If you'd really want to create a working version i'd recommend trying to de-compile the dlls, and put it inside a aspnet core project. 如果您真的想要创建一个工作版本,我建议您尝试对dll进行反编译,并将其置于aspnet核心项目中。 And try to make it build (removing all the errors). 并尝试使其构建(删除所有错误)。

! Be sure to check the licensing and contact Microsoft before thinking about using it or ever publishing it! 请务必检查许可并与Microsoft联系,然后再考虑使用它或发布它!

Alternative solution 替代方案

would be to write a compiler yourself. 就是自己编写一个编译器。

Depending on the scope of features you use in XSLT making a compiler converting the XSLT into a C# class wouldn't be too hard. 根据您在XSLT中使用的功能范围,使编译器将XSLT转换为C#类并不会太难。

You could use the default xml serializer and convert xslt statements to c# statements. 您可以使用默认的xml序列化程序并将xslt语句转换为c#语句。

This would require you to dive into the IViewEngine implementation and build your own version of it for easy use. 这将需要您深入了解IViewEngine实现并构建您自己的版本以方便使用。

Although again i would discourage spending time on this. 虽然我再次不鼓励花时间在这上面。 As it is a lot of work and it is not worth it (In my opinion) for such an old template language. 因为这是一项很多的工作,对于这样一种旧的模板语言来说,这是不值得的(在我看来)。

Yes, we use XslCompiledTransform in our ASP.NET Core 2.0 solution targeting .NET Core. 是的,我们在针对.NET Core的ASP.NET Core 2.0解决方案中使用XslCompiledTransform。

With ASP.NET Core 1 you can target against the full .Net Framework which contains the XslCompiledTransform class. 使用ASP.NET Core 1,您可以针对包含XslCompiledTransform类的完整.Net Framework进行定位。

Since august 2017 XslCompiledTransform is also supported with .NET Core 2.0 and .NET Standard 2.0. 自2017年8月起,.NET Core 2.0和.NET Standard 2.0也支持XslCompiledTransform。 See the Microsoft documentation for all supported .NET versions. 有关所有受支持的.NET版本,请参阅Microsoft文档

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

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