XML

XSL ISAPI Extension

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. 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.

Summary

In this chapter, we discussed two Microsoft technologies that we can use to create data services components that can access data: ADO 2.5 and the SQL ISAPI extension. ADO will allow you to access data in any data store, whereas the SQL ISAPI extension allows you to access data in a SQL 6.5 or 7.0 database. Using ADO and the SQL ISAPI extension, you can create XML data that can be presented to the user and used for updating data.

The XSL ISAPI extension allows you to automatically transform XML documents using XSL on the server when the client does not have Internet Explorer 5 installed. This can be used if you do not want to write ASP pages that use the DOM to perform these translations. In the next chapter, we will look at Microsoft BizTalk Server 2000, a new technology that enables business partners to exchange information.

by BrainBellupdated
Advertisement: