views:

1494

answers:

6

Can anyone (maybe an XSL-fan?) help me find any advantages with handling presentation of data on a web-page with XSL over ASP.NET MVC?

The two alternatives are:

  1. ASP.NET (MVC/WebForms) with XSL
    Getting the data from the database and transforming it to XML which is then displayed on the different pages with XSL-templates.

  2. ASP.NET MVC
    Getting the data from the database as C# objects (or LinqToSql/EF-objects) and displaying it with inline-code on MVC-pages.

The main benefit of XSL has been consistent display of data on many different pages, like WebControls. So, correct me if I'm wrong, ASP.NET MVC can be used the same way, but with strongly typed objects. Please help me see if there are any benefits to XSL.

A: 

If you only going to display data from DB XSL templates may be convenient solution, but if you gonna handle user interaction. Hm... I don't think it'll be maintainable at all.

Artem Tikhomirov
+3  A: 

I've always found two main issues when working with XML transformations:

Firstly they tend to be quite slow, the whole XML file must be parsed and validated before you can do anything with it. Being XML it's also excessively verbose, and therefore larger than it needs to be.

Secondly the way transformations work is a bit of a pain to code - custom tools like XmlSpy help, but it's still a different model to what most developers are used to.

At the moment MVC is very quick and looking very promising, but does suffer from the traditional web-development blight of <% and %> bee-stings all over your code. Using XML transformations avoids that, but is much harder to read and maintain.

Keith
+2  A: 

I've used that technique in the past, and there are applications where we use it at my current place of employment. (I will admit, I am not totally a fan of it, but I'll play devil's advocate) Really that is one of the main advatages, and pushing this idea can be kinda neat. You're able to dynamically create the xsl on the fly and change the look and feel of the page on a whim. Is it possible to do this through the other methods...yes, but it's really easy to build a program to modify an xml/xsl document on the fly.

If you think of using XSL to transform one xml document to another and displaying it as html (which is really what you're doing), you're opening up your system to allow other programs to access the data on the page via XML. You can do this through the other methods, but using an xsl transformation forces it to output xml every time.

I would tread lightly with creating a system this way. You'll find a lot of pit falls you aren't expecting, and if you don't know xsl really really well, there is going to be a learning curve also.

Kevin
+8  A: 

I can see the main benefit of employing XSLT to transform your data and display it to the user would be the following:

  • The data is already in an XML format
  • The data follows a well defined schema (this makes using tools like XMLSpy much easier).
  • The data needs to be transformed into a number of different output formats, e.g. PDF, WMP and HTML

If this is to be the only output for your data, and it is not in XML format, then XSLT might not be the best solution.

Likewise if user interaction is required (such as editing of the data) then you will end up employing back-end code anyway to handle updates so might prove one technology too far...

samjudson
A: 

Jafar Husain offers a few advantages in his proposal for Pretty XSL, primarily caching of the stylesheet to increase page load and reduce the size of your data. Steve Sanderson proposed a slightly different approach using JavaScript as the controller here.

Another, similar approach would be to use XForms, though the best support for it is through a JavaScript library.

Ryan Riley
A: 

Check this out if you want to use XSLT and ASP.MVC

http://www.bleevo.com/2009/06/aspnet-mvc-xslt-iviewengine/

bleevo
Well, I don't want to really. I just wanted some opinions on why anyone would want to use it.
Seb Nilsson
Well the only reason I can think of using it for separating data and presentation is on super high traffic websites were saving 10-20% makes a significant difference.
bleevo