Monday, June 27, 2011

XSL transformations on the brower

Recently, I came across a web framework that was quite unconventional - the framework was performing XML transformations using XSLT on the browser. All web requests were directed to a legacy system that returned XML and this XML was directly sent to the brower. The browser had already loaded the necessary XSL, Javascript and does the XML -> HTML transformation.

There are certain pros and cons of this approach.
Advantages:
  • Clear separation of markup/layout from content.
  • Heavy XSL processing offloaded to the brower, brower JS code can check for brower compatibilities and spit out right markup code.
Disadvantages:
  • All browsers do not support XSL in a standard way. Can be quite a pain to make the look-n-feel compatible with all browsers.
  • Search engines/bots see raw XML, may not be able to interpret and understand.
  • Disables progressive rendering. User won't see anything at all until entire stylesheet and data is loaded completely.
  • XSL is pretty tough to master. Resource skill could become a potential bottleneck.
  • Could run into scalability issues for large XML payloads. When processing XML files, XSLT must load the entire document into memory.
IMHO, although XSLT processing in-browser is fast compared to server side, it is still better if no transformation is required at all. There are tons of server side web-frameworks that can do the job better and faster.