Using Annotations in XSD Schemas (SQLXML 4.0)
In Microsoft SQLXML 4.0, the XSD schema language supports annotations 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 a 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 or attribute.
These annotations can also be used to specify the hierarchical relationships in XML-thus representing the relationships in the database, because an XSD schema is simply an XML view of relational data.
This section provides descriptions of the annotations you can use with XSD schemas and examples of their usage.
Note
All the examples in this section specify simple XPath queries against the annotated XSD schema described in each example. Familiarity with the XPath language is assumed.
In This Section
XSD Annotations (SQLXML 4.0)
Lists the annotations you can use with XSD schemas, their descriptions, and the equivalent annotations for XDR.
Default Mapping of XSD Elements and Attributes to Tables and Columns (SQLXML 4.0)
Explains default mapping and provides examples of tasks related to default mapping.
Explicit Mapping of XSD Elements and Attributes to Tables and Columns (SQLXML 4.0)
Explains explicit mapping with the sql:relation
and sql:field
annotations, and provides examples.
Specifying Relationships Using sql:relationship (SQLXML 4.0)
Describes and provides examples of the sql:relationship
annotation.
Specifying the sql:inverse Attribute on sql:relationship (SQLXML 4.0)
Describes the sql:inverse
annotation.
Creating Constant Elements Using sql:is-constant (SQLXML 4.0)
Describes and provides examples of the sql:is-constant
annotation.
Excluding Schema Elements from the Resulting XML Document Using sql:mapped (SQLXML 4.0)
Describes and provides examples of the sql:mapped
annotation.
Filtering Values Using sql:limit-field and sql:limit-value (SQLXML 4.0)
Describes and provides examples of the sql:limit-field
and sql:limit-value
annotations.
Identifying Key Columns Using sql:key-fields (SQLXML 4.0)
Describes and provides examples of the sql:key-fields
annotation.
Specifying a Target Namespace Using the targetNamespace Attribute (SQLXML 4.0)
Describes and provides examples of the targetNamespace attribute.
Creating Valid ID, IDREF, and IDREFS Type Attributes Using sql:prefix (SQLXML 4.0)
Describes and provides examples of the sql:prefix
annotation.
Data Type Coercions and the sql:datatype Annotation (SQLXML 4.0)
Describes and provides examples of the sql:datatype
annotation.
Mapping XSD Data Types to XPath Data Types (SQLXML 4.0)
Provides a table that compares XSD, XDR, and XPath datatypes and lists the relevant SQL Server conversions.
Creating CDATA Sections Using sql:use-cdata (SQLXML 4.0)
Describes and provides examples of the sql:use-data
annotation.
Requesting URL References to BLOB Data Using sql:encode (SQLXML 4.0)
Describes and provides examples of the sql:encode
annotation.
Retrieving Unconsumed Data Using the sql:overflow-field (SQLXML 4.0)
Describes and provides examples of the sql:overflow-field
annotation.
Hiding Elements and Attributes by Using sql:hide
Describes and provides examples of the sql:hide
annotation.
Using the sql:identity and sql:guid Annotations
Describes and provides examples of the sql:identity
and sql:guid
annotations.
Specifying Depth in Recursive Relationships by Using sql:max-depth
Describes and provides examples of the sql:max-depth
annotation.