Home  >  Article  >  Backend Development  >  Using XML Templates (MSSQL Manual)

Using XML Templates (MSSQL Manual)

黄舟
黄舟Original
2017-03-01 16:40:221234browse

The following is the general form of the template, showing how to specify SQL queries and XPath queries:

 
   
    .. 
    .....n 
   
   
    sql statement(s) 
   
   
    XPath query 
   

Any element in the template is optional. The elements 1aa9e5d373740b65a0cc8f0a02150c53, 0c68fef83818661b6da588c77ca3985e, 708654619547c0a0fe5e1defc275b0b6, 57dbe22da5230054e8cffe8ae1f3024c 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.

b3e08f117497c93350eaf67fc4b5f7c5

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

a7047a4cd2c47b5ef55f8f44976e7bb5

This tag is used to save all header values. In the current implementation, only the 890d0d6974fb473141d6fe1ce33c7b9b element can be specified in this tag. a7047a4cd2c47b5ef55f8f44976e7bb5 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.

890d0d6974fb473141d6fe1ce33c7b9b

This element is used to define the parameters passed to the query within the template. Each 0c68fef83818661b6da588c77ca3985e element defines a parameter. Multiple 0c68fef83818661b6da588c77ca3985e elements can be defined within the a7047a4cd2c47b5ef55f8f44976e7bb5 tag.

610cd9e9a8df248833435b157c4f03a6

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

ce8aaecb80f1b7f3ef757febb0ffa6c4

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 610cd9e9a8df248833435b157c4f03a6 or ca6c78e2cea03519505bd5cf9d5b0c5e represents a separate transaction. Therefore, if you have multiple 610cd9e9a8df248833435b157c4f03a6 or ca6c78e2cea03519505bd5cf9d5b0c5e 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

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


Statement:
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