Why do we do XSL Transformation on the server?

22 05 2008

(This is understandable by people who have basic knowledge of XSL)

In most of the cases XSL transformation is done on the server. Why can’t we do it simply by associating the XSL file to the document XML by adding the XSL reference to it; so that the client (browser) shall do the transformation by itself and display the output on the browser?

Well, this is my understanding about it. Most of the browsers do the transformation by themselves; but browsers which are not capable of doing it, will not be able to transform. So, most of the developers write a JavaScript to make the browser understand this. The script can be as simple as this:

· If the browser supports ActiveXObject, apply XSL template to XML

· Else, create an XSL processor object and import XSL file to it. Use transformToFragment method and apply the XSL style sheet to XML document

This gives the solution, right? Then why do we need server side transformation at all??

We do have another problem here. Browsers which do not have an XML parser cannot understand the JavaScript. [XML Parser is one which converts XML to XML-DOM {Document Object Model} so that it is accessible by JavaScript]. So the solution would be to transform the XSL on the server itself. This can be done by writing an ASP code (for example).

Active Server Pages runs on the server, secured scripting – the user cannot see the code from the browser, responds to the queries of HTML forms, change the content of a webpage.

Transformation on server using ASP:

Create XML parser (XML DOM) -> Load XML file into memory -> Load XSL file into memory -> Transform XML document using XSL into XHTML and send to browser. This HTML is editable at the client side. After editing the data is sent to the server and the XML file is updated (Using ASP). Totally transforming and applying changes to the XML server side – This solution will work in any browser.

- Srikanth


Actions

Information

Leave a comment