Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is preventing widespread use of XSLT for webpages?

Tags:

xml

xslt

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.

like image 475
erjiang Avatar asked Aug 12 '09 19:08

erjiang


People also ask

Does anyone use XSLT anymore?

XSLT is very widely used. As far as we can judge from metrics like the number of StackOverflow questions, it is in the top 30 programming languages, which probably makes it the top data-model-specific programming language after SQL. But XSLT isn't widely used client-side, that is, in the browser.

What is XSLT used for?

The Extensible Stylesheet Language Transformation (XSLT) standard specifies a language definition for XML data transformations. XSLT is used to transform XML documents into XHTML documents, or into other XML documents.

What are the advantages of XSLT?

XSLT brings XML, schemas, and XPath together in a declarative programming language. It is used to query and transform XML (and, with XSLT3, JSON) data, enabling one to express data in new ways, or to create new data based on the content or structure of existing data.

What are the advantages of using XSLT instead of CSS?

If your XML maps pretty nicely to individual layout elements then use CSS, if you need more work in adapting it for display, then use XSLT. Things like arbitrary re-orderings of content or collapsing multiple lists of values into a table, etc. don't lend themselves well to CSS.


2 Answers

  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.

like image 65
scunliffe Avatar answered Oct 24 '22 19:10

scunliffe


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

like image 33
dacracot Avatar answered Oct 24 '22 18:10

dacracot