The XPath queries against annotated XML-Data Reduced (XDR) schema can be specified directly in the URL. For more information about the URL syntax that is supported by the SQL ISAPI extension, see URL Access.
The annotated XDR schemas provide an XML view of the relational data. To execute an XPath query against an annotated XDR schema, the schema file is specified as part of the URL.
To specify an XPath query against an annotated XDR schema, you must create a virtual name of schema type using the IIS Virtual Directory Management for SQL Server utility. The XDR schema specified in the URL must be stored in the directory associated with virtual name of schema type or one of its subdirectories:
http://IISServer/nwind/SchemaVirtualName/XDRSchema.xml/XpathQuery
http://IISServer/nwind/SchemaVirtualName/xyz/XDRSchema.xml/XpathQuery
In this example, nwind is a virtual directory created using the IIS Virtual Directory Management for SQL Server utility, and schema is the virtual name of schema type defined when the virtual directory is created (any name can be given to a virtual name when it is created).
For example, consider this annotated XDR schema:
<?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" />
<AttributeType name="ContactName" />
<AttributeType name="Phone" />
<attribute type="CustomerID" />
<attribute type="ContactName" />
<attribute type="Phone" />
</ElementType>
</Schema>
For illustration purposes, this XDR schema is stored as MySchema.xml in the directory associated with the virtual name of schema type.
This URL executes an XPath query against the XDR schema (MySchema.xml) specified in the URL. The XPath query requests all the customers with CustomerID of ALFKI.
http://IISServer/nwind/schema/Schema2.xml/Customer[@CustomerID="ALFKI"]
This is the result:
<Customer CustomerID="ALFKI" ContactName="Maria Anders" Phone="030-0074321" />
If the query returns more than one customer, you must specify the root keyword to return a well-formed XML document. The following XPath query returns all the customers. In the URL, the root keyword is specified:
http://IISServer/nwind/schema/Schema2.xml/Customer?root=root
This is the partial result:
<?xml version="1.0" encoding="utf-8" ?>
<root>
<Customer CustomerID="ALFKI" ContactName="Maria Anders"
Phone="030-0074321" />
<Customer CustomerID="ANATR" ContactName="Ana Trujillo"
Phone="(5) 555-4729" />
...
</root>