Using XML Templates (MSSQL Manual)

黄舟
Release: 2017-03-01 16:40:22
Original
1367 people have browsed it

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=&#39;XSL FileName&#39; > 
  <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>
Copy after login

Any element in the template is optional. The elements

, , , and the attribute mapping schema are defined in the sql namespace. Therefore, xmlns:sql="urn:schemas-microsoft-com:xml-sql" must be declared in the namespace. You can name the namespace anything you want; sql is just an alias.

Specify this tag to provide a single top-level element (also called the root tag) of the resulting XML document. The tag can be any name.

This tag is used to save all header values. In the current implementation, only the element can be specified in this tag. is used as an inclusion tag, allowing you to define multiple parameters. All parameter definitions are in one location, which makes processing parameter definitions more efficient.

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 tag.

This element is used to specify a SQL query. Multiple elements can be specified in a template.

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 or represents a separate transaction. Therefore, if you have multiple or tags in a template, when one fails, the others will continue.

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
Copy after login

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
Copy after login

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 )!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!