Home arrow ASP arrow Page 3 - XSL Device Formatting Using the Microsoft XSL ISAPI Filter
ASP

XSL Device Formatting Using the Microsoft XSL ISAPI Filter


The XSL ISAPI filter is an extension to Microsoft's Internet Information Services that simplifies the deployment of server-side XSL stylesheets. In this article Jean shows us how to download, configure and use the XSL ISAPI filter to generate output for different devices automatically from IIS, including web browsers and WAP compatible phones.

Author Info:
By: Jean-Baptiste Minchelli
Rating: 5 stars5 stars5 stars5 stars5 stars / 9
March 26, 2002
TABLE OF CONTENTS:
  1. · XSL Device Formatting Using the Microsoft XSL ISAPI Filter
  2. · Installing the filter
  3. · Our sample application
  4. · Conclusion

print this article
SEARCH DEVARTICLES

XSL Device Formatting Using the Microsoft XSL ISAPI Filter - Our sample application
(Page 3 of 4 )

The following code example represents a small application that presents a list of numbers on a single page. Because both WML devices (WAP phones) and HTML devices (Web browsers) will use this application, we will need two stylesheets. In addition, we will also need the .pasp file that will generate the XML as well as a configuration file that will specify which stylesheet should be applied to which device.

The ASP source for generating the XML page (test.pasp) looks like this:

<?xml version="1.0" ?>

<?xml-stylesheet type="text/xsl" server-config="test-Config.xml" href="test-IE5.xsl" ?>

<numbers>

<%

i = 5

while (i > 0)

response.write "<number>" & i & "</number>"

i = i - 1

wend

%>

</numbers>


The code shown represents the .pasp file. This will generate an XML document. In fact, it's simply an ASP file that will generate XML instead of the "regular" HTML.

The XML generated by test.asp looks like this (Note that you will never actually see this XML):

<?xml version="1.0" ?>

<?xml-stylesheet type="text/xsl" server-config="test-Config.xml" href="test-IE5.xsl" ?>

<numbers>

<number>5</number>

<number>4</number>

<number>3</number>

<number>2</number>

<number>1</number>

</numbers>


For each XML document, it's necessary to specify a configuration file that will determine the appropriate XSL stylesheet to use for any given device. The configuration file for our sample application is called test-Config.xml and is shown below:

<?xml version="1.0" ?>

<server-styles-config>

<!-- for WML 1.1 browsers -->

<device target-markup="WML1.1">

<stylesheet href="test-WML11.xsl"/>

</device>

<!-- for Others browsers -->

<device>

<stylesheet href="test-IE5.xsl"/>

</device>

</server-styles-config>


The target-markup attribute value of the device element in the code above must exist in the browscap.ini file. The XSL ISAPI filter uses the associated information as the Content-type for the requests output.

IIS will apply the associated stylesheet to the first matching device. In the above case, if the device accepts WML1.1, IIS will apply test-WML11.xsl -- otherwise it will apply test-IE5.xsl. For browsers like IE 5.5 that can process XSL on their own, developers can choose to leave the XML untouched. For such client-side XSL processing, the XML will be sent to the browser, which will use the specified stylesheet to format the document.

Here's the HTML XSL stylesheet, which is called test-IE5.xsl:

<?xml version="1.0" ?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">

<xsl:template match="/">

<HTML>

<BODY>

<xsl:for-each select="numbers/number">

<xsl:value-of select="text()"/>

<br/>

</xsl:for-each>

</BODY>

</HTML>

</xsl:template>

</xsl:stylesheet>


Here, the XSL file is associated with the default browser. It will output the content of the NUMBERS/NUMBER elements as HTML:

The result on I.E. 6.0

The HTML that's sent to the browser looks like this:

<HTML>

<BODY>

5

<br />

4

<br />

3

<br />

2

<br />

1

<br />

</BODY>

</HTML>


The WML XSL stylesheet (test-WML11.xsl) looks like this:

<?xml version="1.0" ?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">

<xsl:template match="/">

<xsl:pi name="xml">version="1.0"</xsl:pi>

<xsl:doctype>wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"</xsl:doctype>

<wml>

<card>

<p>

<xsl:for-each select="numbers/number">

<xsl:value-of select="text()"/>

<br/>

</xsl:for-each>

</p>

</card>

</wml>

</xsl:template>

</xsl:stylesheet>


This stylesheet will be applied to a WML enabled device, as shown below:

Our page in the OpenWave SDK

The WML generated by the XSL stylesheet looks like this:

<?xml version="1.0"?>

<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">

<wml>

<card>

<p>

5

<br />

4

<br />

3

<br />

2

<br />

1

<br />

</p>

</card>

</wml>

blog comments powered by Disqus
ASP ARTICLES

- Central Scoreboard with Flash and ASP
- Calorie Counter Using WAP and ASP
- Creating PGP-Encrypted E-Mails Using ASP
- Be My Guest in ASP
- Session Replacement in ASP
- Securing ASP Data Access Credentials Using t...
- The Not So Ordinary Address Book
- Adding and Displaying Data Easily via ASP an...
- Sending Email From a Form in ASP
- Adding Member Services in ASP
- Removing Unconfirmed Members
- Trapping HTTP 500.100 - Internal Server Error
- So Many Rows, So Little Time! - Case Study
- XDO: An XML Engine Class for Classic ASP
- Credit Card Fraud Prevention Using ASP and C...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials