Take the 2-minute tour ×

I just learn of ways to use XML data file and XSLT to create a webpage (transform from XML to HTML or XHTML). But I have never seen a webpage that has the source code of XML with a link to an XSLT file. Is it not a good solution?

share|improve this question
add comment

8 Answers

up vote 2 down vote accepted

I do not think it is a good architecture for public-facing web sites:

  • Although most browsers will support client side XSLT, not all will
  • Even if they do, there may be individual browser compatibility issues as with javascript
  • Being able to 'view source' is an incredibly useful tool for debugging. You can't do this with XSL
  • Google supposedly will rank well marked up HTML higher than XML documents
  • XSL is a horrible language
  • You still need to render to XML (unless your data is natively XML), so why not render directly to (X)HTML?

If your data is natively XML, then it might make sense to convert it via XSL on the server side (I have written systems that do this), but that is the only situation and architecture I would use XSL in building a web site.

share|improve this answer
So XSLT is not a good architecture for public-facing web sites just as Javascript isn't? If your data is not XML, the browser can't use client side XSLT. If you need server support, you can use anything available. –  Andreas Aug 13 '10 at 6:54
I don't think XSLT is such a horrible language. But other than that - excellent response! +1 –  Yarik Dec 12 '12 at 5:43
XSLT is supported in most browsers. Android didn't support it in it's stock browser until 2.1, but Opera mini has it, and it's built into Webkit which is a primary library of android. All other arguments appear trivial in stature and really do not supercede the pros of using XSLT. –  annoying_squid Jul 25 '13 at 18:30
add comment

If you already have the data as XML (or its easy to turn it into XML) then I'd say it's a good solution. You probably want to make sure that your web server is configured properly to ensure that the XSLT is getting cached on the client side so that it doesn't have to do the request every time.

If the data isn't in XML already, there are better templating solutions out there (PHP, JSP, ASP, etc.) that are better suited to whatever environment you're in.

share|improve this answer
add comment

Sure there's pages that are generated using XSL+XML, but I bet most of them are parsed server-side, not clientside. Then, if you open an aspx or php page, you can't really tell whether or not it's been parsed from XML and XSL files.

It's quite a decent template mechanism, too. We use it for web pages at our firm, as well as e-mail and some other media. That would be the advantage of XML in this regard; it's not media aware and you can transform your source xml into many formats (most of which will be xml-based).

share|improve this answer
add comment

You’ll have to do the conversion on the server, because not every browser supports XSLT.

share|improve this answer
oh... "most browsers" won't cut it huh... because what if it is a simple browser like Lynx or mobile browser, that probably is the reason. Companies want to show content to any simple browser capable of simple HTML handling. –  動靜能量 Aug 12 '10 at 12:09
All of the major browsers support XSLT including mobile. The problem, as always, will be IE since it cannot handle XHTML. –  Rob Aug 12 '10 at 12:28
I don’t think so. –  Scytale Aug 12 '10 at 12:32
IE is not really a problem here for once - its XSLT support, even in IE6, I've found always found to be acceptable, or at least workable. XHTML doesn't come into it: XSLT (1.0) itself doesn't support XHTML either, since it predates it. –  Will Prescott Aug 12 '10 at 14:50
add comment

Blizzard's world of warcraft websites and their armory website have the only website I've ever seen that sends xml and uses client side xslt to display it. It seems to work quite well and they are pretty high volume sites. (Be aware that it looks at the user agent and does the transformation server side for some browsers, I know it does it client side for IE)

share|improve this answer
I wish I could show a link to a restaurant ecommerce site I'm working on that does the same. It works everywhere and very well except in IE, of course. For that we have to add some javascript. –  Rob Aug 12 '10 at 12:30
add comment

There is a sample PHP Application using XML/XSLT to generate HTML, with server- and client-side demos at Tony Marston's A Sample PHP Application, with plenty of reasoning, howtos and such.

share|improve this answer
add comment

As some already said here, it is a good option when you have the data already in XML format or if you need to publish it to some other places as XML (and thus anyway need to produce XML - this is the case of one of our projects). In this case moving the transformation to client is a good option to take some load from your server(s).

Some browsers don't support XSLT on client side, but most used ones (IE, FF, Chrome) work just fine. The challenge is with browsers for mobile devices. E.g. on Android XSLT is not supported yet. We've handled this by doing device detection on server side (using WURLF - which unfortunately doesn't have a capability flag for XSL support so we had to decide based on device type) and do the transformation on server side only for those devices that can't handle it on client side. Thus we keep as much as we can of the processing on client side, which helps us scale easier without needing hardware upgrades (so far :) ).

Another advantage of using XML would be that you are exporting plain data, which can easily be used but some other tools to do different processing. It's almost like you are providing a web service to get your data already. Can be very convenient for unforseen future usages of your data.

Security: One important aspect that needs to be taken into account if you go for XSLT on client side is to make sure that the XML data that you send to client is not confidential/private (doesn't contain any sensitive information that you might not want some users to see). E.g. if your XSLT shows some data only for some users and would be a security bridge if other would see the hidden data, you'd better do the transformation server side.

Hope it helps.

Cheers, Stef.

share|improve this answer
add comment

It's a good solution if it fits your needs. A client side XSLT transformation is ...
... good because:
- you can use templates on cheap netspace without any server support
- very good for heavy traffic
- the site works even offline on CD/DVD/USB-Stick
- header, footer, navigation etc. is in the XSLT script and loaded only one time, good for speed with many similar pages.
... bad because:
- Some niche browsers may not support XSLT
- you will not be present at google, the XML file ist not appropriate for serch engine spider

share|improve this answer
Can you explain how 'the site works even offline on CD/DVD/USB-Stick' or 'you can use templates on cheap netspace without any server support' any more than a non-XSL site. If there is dynamic data it will need to generate XML anyway, and if it is not, a flat HTML site would be equivalent. So what is the benefit of XSL? –  DanSingerman Aug 12 '10 at 15:06
@DanSingerman: With XSLT you can use dynamic data but it will be processed client side by the browser. The provider serves .xml and .xsl as static files, no difference to serving static html pages. Everything works just the same opening the .xml in your browser as a local file. But e.g. 10 static html pages are 10 x header, menu and footer. With client side XSLT 10 pages are 10 .xml files with specific page data and 1 .xsl file with header, menu and footer. To see this running, look at klassikmotorrad.de –  Andreas Aug 13 '10 at 6:44
add comment

Your Answer


