In-depth discussion of SQL Server 2000 support for XML (iv)

Source: Internet
Author: User
Tags xmlns xpath
XPath query schemas and templates
An XPath query can also be embedded into an XML template file, and the following code is a simple XML template file that contains an XPath query.
<northwind xmlns:sql=
"Urn:schemas-microsoft-com:
Xml-sql ">
<sql:xpath-query mapping-schema=
"File4.xdr" >
/customer[@CustomerID =
' ALFKI ']/order
</sql:xpath-query>
</Northwind>
This query uses a schema (schema) to return all orders for the user with the CustomerID number ALFKI, and if you want the XPath statement to run, you must
Maps different XML elements and attributes to the corresponding database tables and field names using an XDR schema file. This schema file is given below.
<?xml version= "1.0"? > >
<schema xmlns= "Urn:schemas-microsoft-com:xml-data"
xmlns:dt= "Urn:schemas-microsoft-com:datatypes"
Xmlns:sql= "Urn:schemas-microsoft-com:xml-sql" >
<elementtype name= "Customer" sql:relation= "Customers"
<attributetype name= "CustomerID" dt:type= "id"/>
<attributetype name= "CompanyName"/>
<attributetype name= "ContactName"/>
<attributetype name= "City"/>
<attributetype name= "Fax"/>
<attributetype name= "Orders" dt:type=
"Idrefs" sql:id-prefix= "ord"/"
<attribute type= "CustomerID"/>
<attribute type= "CompanyName"/>
<attribute type= "ContactName"/>
<attribute type= "City"/>
<attribute type= "Fax"/>
<attribute type= "Orders" sql:relation=
"Orders" sql:field= "OrderID"
<sql:relationship
key-relation= "Customers"
key= "CustomerID"
foreign-relation= "Orders"
foreign-key= "CustomerID"/>
</attribute>
<element type= "Order" >
<sql:relationship
key-relation= "Customers"
key= "CustomerID"
foreign-relation= "Orders"
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.