In Microsoft® SQLXML 3.0, the XSD schema language supports annotations (with minor differences) in a manner similar to the annotations introduced in the XML-Data Reduced (XDR) schema language. There are additional annotations introduced in XSD that are not supported in XDR.
These annotations can be used within the XSD schema to specify XML to relational mapping. This includes mapping between elements and attributes in the XSD schema to tables (views) and columns in the databases.
If you do not specify the annotations, default mapping takes place. By default, an XSD element with complex type maps to a table (view) name in the specified database and an element or attribute with a simple type maps to the column with the same name as the element/attribute.
These annotations can also be used to specify the hierarchical relationships in XML (thus, representing the relationships in the database because XSD schemas are simply an XML view of relational data).
The following table is a comparison of the XSD annotations that are available in SQLXML with the XDR annotations that were introduced in Microsoft SQL Server™ 2000.
| SQLXML XSD annotation |
Description |
Topic link | SQL Server 2000 XDR annotation |
| sql:relation | Maps an XML item to a database table. | Using sql:relation and sql:field | Same |
| sql:field | Maps an XML item to a database column. | Using sql:relation and sql:field | Same |
| sql:is-constant | Creates an XML element that does not map to any table. The element appears in the query output. | Creating Constant Elements by Using sql:is-constant | Same |
| sql:mapped | Allows schema items to be excluded from the result. | Excluding Schema Elements from the Resulting XML Document by Using sql:mapped | map-field |
| sql:relationship | Specifies relationships between XML elements. The parent, child, parent-key, and child-key attributes are used to establish the relationship. | Specifying Relationships by Using sql:relationship | The attribute names are different:
key-relation foreign-relation key foreign-key |
sql:limit-field sql:limit-value | Allows limiting the values that are returned on the basis of a limiting value. | Filtering Values by Using sql:limit-field and sql:limit-value | Same |
| sql:key-fields | Allows specification of column(s) that uniquely identify the rows in a table. | Identifying Key Columns by Using sql:key-fields | Same |
| sql:prefix | Creates valid XML ID, IDREF, and IDREFS. Prepends the values of ID, IDREF, and IDREFS with a string. | Creating Valid ID, IDREF, and IDREFS Type Attributes by Using sql:prefix | Same |
| sql:use-cdata | Allows specifying CDATA sections to be used for certain elements in the XML document. | Creating CDATA Sections by Using sql:use-cdata | Same |
| sql:encode | When an XML element or attribute is mapped to a SQL Server BLOB column, allows requesting a reference (Uniform Resource Identifier (URI)) to be returned that can be used later to return BLOB data. | Requesting URL References to BLOB Data by Using sql:encode | url-encode |
| sql:overflow-field | Identifies the database column that contains the overflow data. | Retrieving Unconsumed Data by Using sql:overflow-field | Same |
| sql:inverse | Instructs the updategram logic to inverse its interpretation of the parent-child relationship that has been specified using <sql:relationship>. | Specifying the sql:inverse Attribute on sql:relationship | Not supported |
| sql:hide | Hides the element or attribute that is specified in the schema in the resulting XML document. | Hiding Elements and Attributes by Using sql:hide | Not supported |
| sql:identity | Can be specified on any node that maps to an IDENTITY-type database column. The value specified for this annotation defines how the corresponding IDENTITY-type column in the database is updated. | Using the sql:identity and sql:guid Annotations | Not supported |
| sql:guid | Allows you to specify whether to use a GUID value generated by SQL Server or use the value provided in the updategram for that column. | Using the sql:identity and sql:guid Annotations | Not supported |
| sql:max-depth | Allows you to specify depth in recursive relationships that are specified in the schema. | Specifying Depth in Recursive Relationships by Using sql:max-depth | Not supported |
The XSD native targetNamespace attribute replaces the target-namespace annotation that was introduced in the SQL Server 2000 XDR mapping schema. For more information, see Specifying a Target Namespace by Using the targetNamespace Attribute.
All of the examples presented in the topics in this section specify simple XPath queries against the annotated XSD schema described in each example. Familiarity with the XPath language is assumed.
>Annotated Schema Security Issues