The following is the general form of the template, showing how to specify SQL queries and XPath queries:
<ROOT xmlns:sql="urn:schemas-microsoft-com:xml-sql" sql:xsl='XSL FileName' > <sql:header> <sql:param>..</sql:param> <sql:param>..</sql:param>...n </sql:header> <sql:query> sql statement(s) </sql:query> <sql:xpath-query mapping-schema="SchemaFileName.xml"> XPath query </sql:xpath-query> </ROOT>
Any element in the template is optional. The elements
Specify this tag to provide a single top-level element (also called the root tag) of the resulting XML document. The
This tag is used to save all header values. In the current implementation, only the
This element is used to define the parameters passed to the query within the template. Each element defines a parameter. Multiple elements can be defined within the
This element is used to specify a SQL query. Multiple
This element is used to specify an XPath query. Because XPath queries are executed on an annotated XML Data Reduction (XDR) schema, the schema file name must be specified using the mapping-schema attribute.
sql:xsl
This attribute is used to specify the Extensible Stylesheet Language (XSL) stylesheet that will be applied to the resulting XML document. When specifying a mapping schema file, you can specify a relative or absolute path. The relative path specified is relative to the directory associated with the virtual name of the template type. For example, if the directory associated with the virtual name of the template type is C:\Template, then the relative path Xyz/MyXSL.xml specified for sql:xsl will map to C:\Template\Xyz\MyXSL.xml.
mapping-schema
This attribute is used to identify the annotated XDR schema. Specify this attribute only when performing an XPath query in the template. XPath queries are executed on annotated XDR schemas. When specifying a mapping schema file, you can specify a relative or absolute path. The relative path specified is relative to the directory associated with the virtual name of the template type. For example, if the directory associated with the virtual name of the template type is C:\Template, then the relative path (schema/MSchema.xml specified for mapping-schema) maps to C:\Template\Schema\MSchema.xml.
Description Each
If contenttype is set, Sqlisapi.dll returns header information to the browser. If contenttype is not set, urlmon uses the first character in the template file to determine the content type. If the first character in the template is a < character or the Unicode byte order mark (0xFFFE), text/xml is returned to the browser as the content type, and the browser displays the result. Otherwise, Sqlisapi.dll does not send the content-type header information that instructs the browser how to display the results; therefore, the results will not be visible in the browser.
Before you can specify a template in a URL template, you must create a virtual name of type template using the IIS Virtual Directory Management Utility for SQL Server. For more information, see Using the IIS Virtual Directory Management Utility for SQL Server.
Storing templates
Templates are stored in the directory associated with a virtual name of type template or one of its subdirectories:
If the template is stored in a directory associated with a virtual name of type template , the URL query has the following form:
http://IISServer/nwind/TemplateVirtualName/TemplateFile.xml
If the template is stored in a subdirectory associated with the virtual name of the template type (xyz), the URL query has the following form:
http://IISServer/nwind/TemplateVirtualName/xyz/TemplateFile.xml
Namespaces are not supported for XPath queries specified directly in the URL. If you want to use namespaces in XPath queries, you should use template
The above is the content of using XML templates (MSSQL manual). For more related content, please pay attention to the PHP Chinese website (www.php.cn )!