This code uses the sql:xsl attribute to specify the style sheet's name (in this case, HTML.xsl).
To reference an XSLT style sheet in a URL, you place the style sheet in the root virtual directory or one of its subdirectories (e.g., http://localhost/xmlquery). You then append &contenttype=text/html&xsl=html.xsl to the URL. So, for example, if you want to search for titles that contain the word Computer, the URL would be
http://localhost/xmlquery/templates/query3
.xml?Title=Computer&contenttype=text/html&
xsl=html.xsl
The Finishing Touches
At this point, you've created a search application whose retrieved records display in the correct format on both Web and WAP browsers. However, the search form you created earlier works on only Web browsers. Thus, you need to provide a search form for WAP browsers. The file Search.wml, which Listing 6 shows, creates a WAP search form similar to the one that Figure 7 shows.
You now have two search forms. Instead of relying on users to enter the correct filename (i.e., Search.html or Search.wml) to display the correct search form for their type of browser, you can use an Active Server Pages (ASP) file to automatically determine whether a user needs the HTML or WML search form. As Listing 7 shows, the Redirect.asp file checks the HTTP_ACCEPT environment variable to see whether it contains the string wap. If it does, the Search.wml file executes; otherwise, the Search.html file runs. To use Redirect.asp, you must set the WML MIME type (for files with the .wml extension) on your Web server. If you don't, you'll receive error 406.
Concentrate on What's Important
With the process I've demonstrated, you can access SQL Server 2000 database records without writing any ADO code. This process is especially useful if you need to build applications that retrieve and display database information for remote or mobile users. Instead of getting unduly concerned with the intricacies of database access, you can rely on SQL Server 2000's XML support. That way, you can concentrate on building applications that meet the needs of all your users, whether they're using Web or WAP devices.