tags:

views:

870

answers:

12

Why aren't more webpages written using XML with an XSLT stylesheet? For separating content from presentation, this combined with CSS would be even more powerful. Right now, for things like outputting a navigation menu, people often hand-copy the navmenu code from page to page or do something like

<?php include_once('myheader.inc'); ?>

on every page, which not only puts more demand on the server, but results in duplicated data transmitted.

When I was introduced to it, I was told that all major browsers back to IE6 support XSLT 1.0... are there unresolvable bugs between implementations? Are there others showstoppers or severely lacking features that are inhibiting the spread of XML+XSLT? The only website I've seen lately that is XML+XSLT is starcraft2.com.

+5  A: 

I think part of the issue is that programming in XSLT has some of the attributes of a functional language (see this answer for why it's not fully functional).

As such it requires a different approach from the 'usual' imperative mindset, and that will deter some people from fully investigating it (I'm not dismissing functional programming, btw, but in the web client/server world it's not the most common paradigm).

In the Java world it used to be perceived as being slow and memory hungry. I'm sure some of that was anecdotal, and perhaps partly the effect of early VMs. I note, however, that hardware XML accelerators are available and sit behind the JAXP interface, so perhaps there's still a speed issue ?

Brian Agnew
+1 Put simply, XSLT is a pain in the ass to use for all but certain narrow tasks.
skaffman
I wouldn't be so rude :-), but after being told that the way to manipulate XML in Ant was to use XSLT, I developed XMLTask (Google it) to do XML in Ant. Horses for courses, etc.!
Brian Agnew
+2  A: 

There are a few issues regarding the adoption of XSLT, browser issues among others. For instance, the Firefox plugin NoScript, designed for blocking malicious JavaScript, also blocks XSLT on unknown pages. Don't forget that switching to a subdomain or different protocol will make IE respond to it as a violation of the same origin policy. Still, XML+XSLT, even though it's just for a limited number of cases, is quite useful. See WoW's website as an example of well-implemented XML+XSLT.

Electro
Starcraft2 and WoW both being Blizzard properties, we've come up with a grand total of 1 company that uses it. :(
erjiang
+3  A: 

XSLT isn't easy.

tuinstoel
Too hard... sorry but that doesn't cut it.
dacracot
I'm just a simple man in a high tech digital world, see http://www.youtube.com/watch?v=wY5bLLXMUgQ
tuinstoel
It's not that it isn't easy, it just requires a different way of thinking. It's a rule based rather than procedural language. If you can think rule based, it's not all that hard.For data transformation it's more logical and effective than procedural statements.
tjmoore
A: 

Browsers do a piss poor job of rendering XSLT... meaning that to get it to render properly across browser, you need to render it on the server, negating any advantage you had for using it in the first place.

This means that you end up doing two conversions on the server side instead of one: data -> XML -> HTML instead of data -> HTML.

R. Bemrose
Actually, no, Electro did NOT point out that browsers do a poor job rendering XSLT. He only said that security is strictly enforced.
erjiang
A: 

Simple, XSLT is far too complicated.

Gary Willoughby
Too hard... sorry but that doesn't cut it.
dacracot
@dacracot: When it comes to widespread adoption it does
Adam Byrtek
+1  A: 

XSLT in the browser is right out because the smallest mistake in generating valid XML input could cause your page to show up blank, but there's a product called deliverance that runs on the server to make different web applications in a site share the same theme.

XSLT is surprisingly fast. It will be much faster than a typical interpreted templating language on the backend.

joeforker
+13  A: 
  1. It is extremely verbose
  2. It is hard to trace (in a complex system) how/where/why/when a template is called
  3. Since the output must be well-formed you can't have a template that "opens" the HEAD or BODY tag that you'll then worry about closing somewhere else later. This sucks when you want to be able to queue up bits of code to go into the HEAD when you are processing what will be in the BODY.
  4. It isn't as easy to navigate the code as following method calls is
  5. Outputting something like an IE conditional comment is very confusing with all the escaping needed
  6. Building a string of HTML by appending bits just doesn't work. This can be overcome by building the HTML string bit by bit in XSL code, but it becomes quite complex.

However most of all (IMHO) it adds an extra layer to the process that doesn't "buy" you much.

e.g. typically you have:

DB > SQL > [JAVA|PHP|ASP|Python|Ruby] > HTML

but if you throw XML and XSL in, you've added steps that (can be) hard to justify

DB > SQL > [JAVA|PHP|ASP|Python|Ruby] > XML > XSL > HTML

having the data in a handy dandy universally exchangeable XML format is great-n-all, but unless you need it, all you've done is add steps.

Now I shouldn't knock XSL too much because, well I use it all the time and do appreciate some of the powerful options it provides. However to anyone deciding if they want to use it, be sure you have a need before diving in.

scunliffe
I couldn't agree more with you. I don't know who thought it would be great to take markup like html or xml which is already verbose and difficult to read and embed more markup but this time with complex branching and looping. The thought scares me.
Matthew Manela
+1 for extremely verbose.
liori
Your point of "DB>SQL>[JAVA|PHP|ASP|Python|Ruby]>XML>XSL>HTML" is well taken. But when you DO need it, it is awesome. If you wanted to provide a web page and a web service with the same back end, only the XSL presentation code would have to change.
dacracot
Not extremely, just verbose. XSLT has it's places - esp. where there's an existing XML output, you can make a web from it with almost no effort.
Ondra Žižka
Re: "extremely" I guess it depends on your perspective. If I compare the code needed to take an XML nodeSet and render an HTML Select list with logic to select the "current" value etc. - vs. what it would take me to output a list/map in PHP/Ruby/etc. the difference is pretty obvious to me.
scunliffe
+4  A: 

Blizzard Entertainment seems to like XSLT. Their World of Warcraft Armory site is completely implemented using it. Look around the site using view source.

dacracot
Why was this voted down? It's a very good example of one of the very few sites that use XSTL extensively for their website
John Burton
Because it is WoW. People can't seem to separate their emotions about the game and its tech.
dacracot
A: 

XSLT is an ugly, ugly template language. It has some advantages, but is also missing some critical features. Django features a template language for designers to give them simple access to data elements. They have considered XLST before, but consider it simple to change out. PHP users may prefer something like Smarty.

Obviously your question focuses on moving this to the browser, where the choices are basically XSLT, CSS or Javascript. I'm guessing the people who are in charge of CSS are not the same as those in charge of Javascripting.

jldugger
XSLT is anything but a "template language". It bears no resemblance it "something like Smarty" *whatsoever*. If you think that's what XSLT is for then you are completely on the wrong track.
Tomalak
XSLT is for writing templates and placing data from XML in it. The difference between smarty and XSLT is that XSLT requires XML input, and requires that XSLT itself be XML compliant.
jldugger
No XSLT is a rule based transformation language.
tjmoore
A: 

XSLT was one of the few XMLish technologies that I actually liked. Especially for report generation the concept of XSLT with its set-based feel and ability to target all kinds of output formats (not just html) it deserves to be used more than it is today.

The reason I personally never used it was because at the time one of the browsers (I believe IE7) did not support rendering XSLT in the browser and we did not have the option of XSLT processing on the server side.

The second reason is that while its great for reporting and data presentation it wasn't really practical in terms of general purpose use.

Einstein
A: 

People who didn't live under a rock for the last ten years don't copy and paste header code or use PHP includes for layout anymore. They separate presentation from the actual code and use templating systems (eg. Smarty, a popular one for PHP) which have syntax that is easier to comprehend and reason about than XSLT.

Adam Byrtek
In an ideal world ...
erjiang
It's easier to convince somebody to use a templating system than XSLT, especially when it comes to designers and front-end developers.
Adam Byrtek