| Advertise Here |
DEVELOPER CHANNEL |
XSL - On the ServerA Cross Browser SolutionIn the previous chapter I explained how XSL can be used to transform a document from XML to HTML in the browser. The trick was to let the JavaScript use an XML parser to do the transformation.This solution will not work with a browser that don't support an XML parser. To make our XML data available to all kinds of browsers, we have to transform the XML document on the SERVER and send it as pure HTML to the BROWSER. That's another the beauty of XSL. One of the design goals for XSL was to make it possible to transform data from one format to another on a server, returning readable data to all kinds of future browsers. XSL transformation on the server is bound to be a major part of the Internet Information Server work tasks in the future, as we will se a growth in the specialized browser marked (think: Braille, Speaking Web, Web Printers, Handheld PCs, Mobile Phones .....). The XML file and the XSL fileTake a new look at the XML document that you saw in the previous chapter (or open it with IE5):
And at the companying XSL stylesheet (or open it with IE5):
The syntax of the above XSL document was explained in the previous chapter, so it will not be explained here. But be sure to notice that the XML file does not have a reference to the XSL file, and the XSL file does not have a reference to the XML file. IMPORTANT: The above sentence indicates that an XML file on the server could be transformed using many different XSL files. Transforming XML to HTML on the ServerHere is the simple source code needed transform the XML file to HTML on the server (View it in your browser):
(The example is an ASP file, and the code is a VBScript. If you don't know ASP or VBScript you should take a trip to ASP School.) The first block of code creates an instance of the Microsoft XML parser (XMLDOM), and loads the XML file into memory. The second block of code creates another instance of the parser and loads the XSL document into memory. The last line of code transforms the XML document using the XSL document, and returns the result to the browser. Nice and simple. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Jump to : Top Of Page or HOME |