XSL ISAPI Extension

[Previous] [Next]

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:

  1. Expand the files into a folder in your local drive. You will see numerous headers for C++, but we are interested in only Xslisapi.dll.
  2. Copy the Xslisapi.dll file into the %SystemRoot%\SYSTEM32\INETSRV directory.
  3. Open the Internet Services Manager console, right click on the default Web site, and select Properties as shown in Figure 15-7.
  4. Figure 15-7. Opening Properties Window in the default Web site.

  5. In the Properties window, select the Home Directory tab and then click on the Configuration button.
  6. Select the App Mappings tab and click Add.
  7. Type in Xslisapi.dll as the executable and .xml as the extension. If you are using IIS 5 (Microsoft Windows 2000), click Limit To and add HEAD, GET. If you are using IIS 4, enter PUT, POST>, DELETE in the method exclusions box.
  8. Finally, clear the Script engine check box and select Check That File Exists check box. If you are using Internet Explorer 5 in Windows 2000, the configuration would appear as shown in Figure 15-8. Click OK twice.
  9. click to view at full size.

    Figure 15-8. Application Mappings for Internet Explorer 5.

  10. In the Home Directory tab's Execute Permissions box, select Scripts And Executables so that the xslisapi DLL is allowed to execute over any XML document on your Web site.
  11. Click OK and close the Properties window.
  12. 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.



Developing XML Solutions
Developing XML Solutions (DV-MPS General)
ISBN: 0735607966
EAN: 2147483647
Year: 2000
Pages: 115
Authors: Jake Sturm

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net