In Chapter 12, we created an ASP page that used the DOM to transform an XML page to XHTML on the server using an XSL document. Instead of writing your own code to perform XSL transformations on the server, you can use the XSL ISAPI extension to automatically transform an XML page that includes a reference to an XSL page if the browser is not Internet Explorer 5. If the browser being used is Internet Explorer 5, the XML page is sent to the client as is, and the transformation is done on the client. For the most part, the XSL ISAPI will be working with data and transforming it according to a set of rules defined in an XSL document.
The Xslisapi.exe file is a zipped file that contains the files for the ISAPI extension. This file can be found at http://msdn.microsoft.com/downloads/webtechnology/xml/xslisapi.asp. To install this extension on a server running IIS, follow these steps:
Figure 15-7. Opening Properties Window in the default Web site.
Figure 15-8. Application Mappings for Internet Explorer 5.
At this point, each request for an XML file that contains the processing instruction <?xml-stylesheet type='text/xsl' href='yourstyle.xsl'?> will go through the xslisapi DLL.
If the requesting browser is Internet Explorer 5, the xslisapi DLL will pass the XML document directly to the client. Otherwise, the xslisapi DLL will perform the XSL transformation on the server.
You can use a different style sheet for server-side processing and client-side processing by using a server-href attribute within the same processing instruction. If the xslisapi DLL needs to do server-side processing, it will first look for the server-href attribute. If the attribute is there, it will use the XSL page referenced by server-href. If the client doesn't have Internet Explorer 5 installed, the style sheet referenced by the server-href attribute will be used to transform the document. Thus, we would rewrite the processing instruction as follows:
<?xml-stylesheet type="text/xsl" server-href="serversideStyle.xsl" href="yourstyle.xsl"?> |
You can also add a special Config.xml file into the same directory as the xslisapi DLL. This configuration file is optional and gives additional instructions to the xslisapi DLL.