Microsoft KB Archive/278500

From BetaArchive Wiki
Knowledge Base


How To Specify an XSL File to Transform the XML Stream from a Query with SQL Server 2000

Article ID: 278500

Article Last Modified on 7/13/2004



APPLIES TO

  • Microsoft SQL Server 2000 Standard Edition



This article was previously published under Q278500

SUMMARY

This article demonstrates how to specify an XSL file as a parameter on a post to a SQL Server 2000 virtual root.

MORE INFORMATION

This article is based on the assumption that the reader is familiar with the configuration for SQL Server 2000's virtual root and associated virtual names for templates and schema. The virtual root and virtual names are set up through the Configure SQL XML Support in IIS utility. For additional information, see SQL Server Books Online. The Help page for this utility is called "Creating the nwind Virtual Directory."

This article assumes the following configuration:

Virtual Root Element Drive Path
Virtual Root C:\VirtualRoot
DbObject N/A
Template C:\VirtualRoot\Template
Schema C:\VirtualRoot\Schema



When you are specifying an XSL file on a URL for a template query it may be somewhat confusing. For example, when a template file contains a reference to an XSL style sheet, the style sheet would be specified using "sql:xsl=" as shown in the following example:

<ROOT xmlns:sql="urn:schemas-microsoft-com:xml-sql" 
      sql:xsl='SomeXslFile.xsl'>
                


Additionally if the template file contains an XPath query, the template file would reference the associated mapping schema located within the schema directory "C:\VirtualRoot\Schema" by using "mapping-schema=" as shown in the follow snippet from a template file:

<ROOT xmlns:sql="urn:schemas-microsoft-com:xml-sql" 
      sql:xsl='SomeXslFile.xsl'>
    <sql:xpath-query mapping-schema="../schema/TestSchema.xdr">
                


There is an assumption many people make when they make the transition to specifying the XSL on the post for the template query. Many consider the Template directory analogous to a "working directory" especially when considering how the mapping schema is referenced for an XPath query example. However, when the XSL file is specified on the URL request to explicitly point to the XSL file shown below, the request must specify the path to the XSL file relative to the VirtualRoot, which is "C:\VirtualRoot". Therefore, if the Template file is in the Template directory "C:\VirtualRoot\Template", the XSL file would have to be specified as "XSL=Template/SomeXslFile.xsl" as shown in the following example:

http://www.ServerName.com/VirtualRoot/Template/Template.XML?XSL=Template/SomeXslFile.xsl
                


This behavior is by design. For additional information, see SQL Server Books Online. The Help page titled "Specifying an XSL Style Sheet in a Template" covers this subject in more detail.


Additional query words: template query xsl sql url xml

Keywords: kbhowto KB278500