DOWNLOAD THE CODE:
Download the Code 22395.zip

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.

End of Article

Prev. page     1 2 [3]     next page -->



You must log on before posting a comment.

If you don't have a username & password, please register now.

Reader Comments

Hi All...

Have anyone been able to get the XSLT style sheet to work properly? When I try to view the raw XML by changing

<Titles xmlns:sql="urn:schemas-microsoft-com:xml-sql">

to

<Titles xmlns:sql="urn:schemas-microsoft-com:xml-sql" sql:xsl="HTML.xsl">

on my page(Query3.xml), I got this:

- <html> - <body bgcolor="white"> <table border="0" /> </body> </html>

My HTML.xsl page is a exact copy of the sample HTML.xsl.

Bobby

Bobby Ma

I also got this error message when I tried to view the page with the XSL stylesheet in the URL:

http://dev.bobbyma.com/xmlquery/templates/Query2.xml?Title=Computer&contenttype=text/html&xsl=HTML.xsl

ERROR: 500 Internal Server Error HResult: 0x80004005 Source: Microsoft XML Extensions to SQL Server Description: SQLXML: error loading XSL stylesheet

and without the XSL stylesheet in the URL: http://dev.bobbyma.com/xmlquery/templates/Query2.xml

Bobby

Bobby Ma

I posted a comment about a couple of weeks ago about error messages

Bobby Ma

The instruction on how to configure IIS to work with XML is not clear at all. I was able to creat all necessary files for this Hands-On XML sample, but I could not make it to work without knowing how to configure in IIS to work with XML Would you please let me know the exact steps on how to do this configuration. I appreciate your help because I really wanted to make this sample work. Thanks in advance. Lynn Dang I Work for www.Abaristech.com

Lynn Dang

 
 

ADS BY GOOGLE