views:

1365

answers:

7

I am in the preliminary stages of planning a project with a client to redo their current website. I took a look at their current site to see what issues they are currently dealing with and upon inspection I noticed that every page is being rendered entirely using XSLT. I am familiar with XSLT, I have used it to render custom controls that need to be refreshed often on the client-side, but never to render an entire page.

Help me become less ignorant, what could be the reasoning behind this? What benefits or disadvantages does this bring to the table?

+3  A: 

Sounds like they did it because they knew XSL-T very well and already had XML data on hand.

I wouldn't like the solution myself. XSL-T isn't the easiest thing to read or write. It doesn't lend itself well to visualizing how a page will look. It cuts designers and web developers out of the process. And it doesn't internationalize well. There's nothing equivalent to Java resource bundles that can pull out locale specific information. I don't consider cut & paste a good solution.

duffymo
+4  A: 

Server-side:

Advantages:
  • Clean, concise templates
  • An easy way to process XML data into HTML
  • Reasonably fast
Disadvantages:
  • Programming model unfamiliar and uncomfortable for many procedural-language programmers
  • Awkward if some or all source data is not in XML
  • Can be very slow when not used carefully (small changes can have large repercussions)


Client-side:

Advantages:
  • A convenient way to off-load processing onto client code, where scripts can potentially have much better knowledge of how best to format the resulting HTML.
Disadvantages:
  • Browser support is all over the map.
  • Google won't thank you.
Shog9
To mitigate client-side disadvantages, you could detect user-agent headers on the server and switch to server-side rendering as needed. This way if an older browser, googlebot, msnbot, etc. hit your site, you could do the transformation to html for them.
Michael Petito
+1  A: 

XSLT on client side

  • Disables progressive rendering. User won't see anything at all until entire stylesheet and data is loaded completely.
  • Not supported by search engines and other crawlers. They'll see raw XML.
  • Not supported by older/less advanced browsers.

XSLT in general

  • Unless you carefully design your stylesheets, they may quickly become difficult to maintain:
    • with numerous templates it may be very difficult to figure out which templates are applied.
    • verbosity of XSLT and XML syntax make it hard to understand anything at glance.
    • XPath tricks are tempting, but nightmare to modify later.
porneL
A: 

Sounds like the All-singing-all-dancing XML fetish.

Since you can do anything with XSLT, might as well do everything. I've had people ask why a data warehouse isn't just XSLT transforms between input, data mart and reports.

Advantage. Everything's in XML.

Disadvantages.

  • Not very readable. Your page templates are bound up as XSLT transformations with confusing looping and conditional processing features.

  • Any change to page templates requires an XSLT expert, in addition to the graphic designer who created (and debugged) the HTML and CSS.

S.Lott
A: 

Biggest benefit: platform neutral way to render xml

Biggest disadvantage xsl is difficult to maintain

I've once had to work with an xsl over 4,000 lines long that also includes several other xsl templates. Now that was hard to work with!

barneytron
A: 

I think XSLT is great when built the right way(We use a framework of templates at work).

Sveisvei
A: 

The answers above provide a good survey of some of the advantages and disadvantages of XSLT. I'd like to add another disadvantage. We have found that you pretty quickly run into scalability issues when using XSLT for moderately large datasets.

When processing XML files, XSLT must load the entire document into memory. With Xalan, this consumes roughly 10x the size of the input file (saxon has an alternative DOM implementation that uses less memory). If any of your input datasets grow beyond a couple of hundred megabytes, your XSLT processor might just flake out.

cddr