Monday, January 30, 2012

Is Razor or XSLT better for my project?

I've read an very good article about XSLT and RAZOR. Some people think XSLT is better when you are using Multiple templates.

I don't agree with that. For me, Xslt is good for only static html pages. (no server codes). When you need to use server code, it's a lot difficult to control with XSLT.

XSLT or Razor would help to provide a separation of concerns where the original XML or response represents your model, the XSLT or 'Razor view' represents your view. I'll leave the controller out for this example. The initial design proposal recommends XSLT, however I suggested the use of Razor instead as a more friendly view engine.

These are the reasons I suggested for Razor (C#):

Easier to work with and build more complicated pages.

Can easily produce non-*ML output, eg csv, txt, fdf

Less verbose templates

The view model is strongly typed, where XSLT would need to rely on convention, eg boolean or date values