Razor模板存在时使用XSL的原因 [英] Reasons for using XSL when Razor templates exist

查看:265
本文介绍了Razor模板存在时使用XSL的原因的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在有Razor模板引擎存在,继续使用XSL模板有什么好的理由吗?

Are there any good reasons to continue using XSL templating now that the Razor templating engine exists?

根据我所见:


  1. Razor模板引擎这更接近C#(或VB),这是你已经用来编写服务器代码,而XSL模板有一个类似XML的语法,要求开发人员至少学习XML的基础。

  2. 您可以直接使用现有的对象模型,而无需先将其转换为XML。

  3. Microsoft仅支持XSL 1.0版,

注意 :如果你想回答这个问题,请尝试避免使用一种语言的个人原因,并关注为什么一个人比另一个有优势的实际技术/实践原因。因为你可能已经注意到我已经建立了一个偏好,但我想尽可能保持这一点。

Note: If you want to respond to this question, please attempt to avoid personal reasons for using one language over the other, and focus on actual technical/practical reasons for why one has an advantage over another. As you have probably already noticed I have already established a preference, but I'm trying to keep this on point the best that I can.

在我目前的情况下,我从数据库中获取数据并将其单独转换为XML ,然后使用XSLT将其转换为有效的HTML然后呈现给用户。从我的角度来看,似乎更直接转换为一个对象模型,然后从Razor模板中使用。就我个人而言,我认为比我目前的流程更容易维护和涉及更少的代码。然而,我想给XSLT一个公平的摇摆,然后我做出一个rash决定从XSLT转换为剃刀,并希望两者之间更直接的比较。 (

In my current situation, I take data from a database and convert it into XML solely to then use XSLT to transform it into valid HTML, which is then rendered to the user. From my point of view it would seem more practical to convert directly into an object model which would then be used from within Razor templates. Personally I feel it would be easier to maintain and involve less code than my current process. However I'm trying to give XSLT a fair shake before I make a rash decision to convert from XSLT to Razor, and would like a more direct comparison between the two. (Side note: this is not a process I have chosen, but rather one that I'm being told to use.)

>再次,请尽量不要离太远的点。我的目标是对XSLT和Razor进行技术/实用比较,以便我能够确定哪种技术最适合我的情况。

Again, please try to not stray too far from the point. My goal is for a technical/practical comparison of XSLT and Razor so that I can determine which technology works best for my situation.

推荐答案

我在一个在开发基于ASP.NET表单的应用程序时严重依赖XSL的组织工作。当他们搬到MVC / Razor XSL完全放弃。主要是因为你列出的原因1和2。从维护的角度来看,使用Razor更容易,因为进入组织的新开发人员可以比XSL更容易接收Razor,并且更有可能已经拥有Razor技能,而不是XSL。在对象和XML之间来回转换需要更多的编码,并且使用对象允许您使用InteliSense,我相信这是一个巨大的生产力增益。我还要补充说,使用Razor更容易调试,它是一个更干净,更简洁的语法。

I worked in an organization that relied heavily on XSL when developing ASP.NET forms based applications. When they moved to MVC/Razor XSL was totally dropped. Mostly for reasons 1 and 2 that you listed. From a maintenance standpoint it was easier to just use Razor because new developers coming into the organization could more easily pick up Razor than XSL, and are more likely to already have Razor skills as opposed to XSL. Converting back and forth between objects and XML requires a lot more coding and also working with objects allows you to use InteliSense, which I believe is a big productivity gain. I would also add that using Razor is easier to debug and it is a cleaner and more succinct syntax.

这篇关于Razor模板存在时使用XSL的原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆