Home > Articles > Web Services > XML

  • Print
  • + Share This
From the author of

Tools Needed for XSL Transformation

Using XSL Transformations to create Web pages out of XML requires an XSL processor. This is the software that actually takes in the XML file and transforms it according to the style sheet.

How you obtain this processor will depend on how you're going to do the Transformations. For simple, non-dynamic Transformations, Microsoft's Internet Explorer is enough; it has its own processor within it. You can access the XML file locally to test it, or any Web server can serve it, and the browser retrieves the style sheet and performs the transformation, showing the user the intended HTML. (This is all you will need for Article 2.)

There are, of course, difficulties with the "client-side" approach. First, and most importantly, if you can't predict what type of browsers your users will have, you can't guarantee that they will actually be receiving the transformed page. Instead, if the browser doesn't support XSL Transformations, the user will just receive an XML file that means nothing to them. Second, it is difficult, if not impossible, to choose which style sheet to use, which defeats the whole purpose of adding personalization to the site. Dynamic style sheets are also virtually impossible to create.


It is not actually impossible to do these things, if you are assuming that the user has Internet Explorer. Many of the same techniques we will discuss when implementing this project for Internet Information Services (IIS) can be adapted and implemented in the browser, but this will eliminate any possibility of cross-browser availability of your content.)

To solve both of these problems, it is often preferable to transform the XML on the Web server and then send the HTML to the browser. Which tools you need to do this will depend on the operating system and programming environment you prefer. Overall, you need a Web server capable of generating dynamic content (such as Active Server Pages, Java servlets or Java Server Pages, or CGI) and an XSLT processor.

Microsoft-Based Solutions

Performing server-side XSL Transformations using Microsoft products basically requires that you are running Microsoft Internet Information Services (IIS) version 4 and up, and that you have the Microsoft XML Parser (MSXML) on the server. A version of MSXML is installed with IE 5.x and above, but later versions are available. At the time of this writing, the current public release is MSXML 3, which has great improvements over earlier versions. MSXML 3 can be downloaded from http://msdn.microsoft.com/code/default.asp?url=/code/sample.asp?url=/msdn-files/027/001/596/msdncompositedoc.xml.

Java-Based Solutions

To transform XML files into HTML using Java, you need a Web server that supports either Java servlets or Java Server Pages, such as Jakarta Tomcat. (Examples will be shown using servlets for simplicity's sake, but the concepts and coding are virtually the same for JSPs.) You can download Tomcat from http://jakarta.apache.org/tomcat/index.html.

As far as an XSLT Processor, there are also several available. We will use Xalan Java 2, available from the Apache project at http://xml.apache.org/xalan-j/index.html.

Other Platforms and Environments

Although these articles will only show sample code for Java and Active Server Pages, the overall concepts apply to any environment. XSLT Processors are available in many languages, including C++, Perl, and Python, as well as Java. Transforming an XML file into an HTML page can just as easily be performed through CGI, or through another application server system. For a list of XSLT engines, see http://www.xslt.com/xslt_tools_engines.htm.

  • + Share This
  • 🔖 Save To Your Account