|
||
| Inside Technique : Building Smart Pages with ASP, XML and XSL : The ASP Script Our ASP page checks the browser you are using and delivers the appropriate. If you are not running Internet Explorer 5.0 we open the XML document, apply the XSL transformation, and send the resulting HTML to the client. In Internet Explorer 5.0 we send the XML and XSL files directly to the client for processing. Creating this logic is very easy. The first step is to make sure you have the Microsoft XML and XSL parsers installed on your server. If you are running Internet Explorer 5.0 on your server these parsers are already installed. If not, you need to download and install them from Microsoft's XML site. Next you need to author the server-side script. The server script first
determines the client's browser. This can either be accomplished using the IIS Browser Capabilities
object or by analyzing the HTTP header directly. We do our browser detection by analyzing
the header directly:
The next step is to write your script that uses the browser version
to return the correct document. If you are running IE5, we send the XML document directly to the
client, otherwise we generate the HTML on the server:
At this point, we recommend you view our simple demo page. This is the same XML demonstration page from our first article. However, now it is viewable by all browsers. You should view the demo page and source in both Internet Explorer 4.0 or later and Netscape Navigator. You will notice the HTML is different depending upon your browser, and in the case of IE5, you are viewing the XML file directly. While the file appears different on the client, the presentations were created from the same source XML document (all the files are available for download at the end of this article). Since the presentation is separate from the source article, we only need to update one file to change the original article. We can also tweak the layout of all articles just by changing the appropriate XSL style sheet. The next step is to explain how we perform the transformations on the server by explaining TransformDocument and OutputDocument functions. Page 1:Building Smart Pages with ASP, XML and XSL © 1997-2000 InsideDHTML.com, LLC. All rights reserved. |