Requirements and Limitations for XML Schema Collections on the Server


Applies To: SQL Server 2016

The XML schema definition language (XSD) validation has some limitations regarding SQL columns that use the xml data type. The following table provides details about those limitations and guidelines for modifying your XSD schema so it can work with SQL Server. The topics in this section provide additional information about specific limitations and guidance for working with them.

minOccurs and maxOccursThe values for minOccurs and maxOccurs attributes must fit into 4-byte integers. Schemas that do not conform are rejected by the server.
<xsd:choice>SQL Server rejects schemas that have an <xsd:choice> particle without children, unless the particle is defined with a minOccurs attribute value of zero.
<xsd:include>Currently, SQL Server does not support this element. XML schemas that include this element are rejected by the server.

As a solution, XML schemas that include the <xsd:include> directive can be preprocessed to copy and merge the contents of any included schemas into a single schema for upload to the server. For more information, see Preprocess a Schema to Merge Included Schemas.
<xsd:key>, <xsd:keyref>, and <xsd:unique>Currently, SQL Server does not support these XSD-based constraints for enforcing uniqueness or establishing keys and key references. XML schemas that contain these elements cannot be registered.
<xsd:redefine>SQL Server does not support this element. For information about another way to update schemas, see The <xsd:redefine> Element.
<xsd:simpleType> valuesSQL Server only supports millisecond precision for simple types that have second components other than xs:time and xs:dateTime, and 100-nanosecond precision for xs:time and xs:dateTime. SQL Server puts limitations on all recognized XSD simple type enumerations.

 SQL Server does not support using the "NaN" value in <xsd:simpleType> declarations.

For more information, seeValues for <xsd:simpleType> Declarations.
xsi:schemaLocation and xsi:noNamespaceSchemaLocationSQL Server ignores these attributes if they are present in the XML instance data inserted into a column or variable of xml data type.
xs:QNameSQL Server does not support types derived from xs:QName that use an XML Schema restriction element.

 SQL Server does not support union types with xs:QName as a member element.

For more information, see The xs:QName Type.
Adding members to an existing substitution groupYou cannot add members to an existing substitution group in an XML schema collection. A substitution group in an XML schema is restricted in that the head element and all its member elements must be defined in the same {CREATE | ALTER} XML SCHEMA COLLECTION statement.
Canonical forms and pattern restrictionsThe canonical representation of a value cannot violate the pattern restriction for its type. For more information, see Canonical Forms and Pattern Restrictions.
Enumeration facetsSQL Server does not support XML schemas with types that have pattern facets or enumerations that violate those facets.
Facet lengthThe length, minLength, and maxLength facets are stored as a long type. This type is a 32-bit type. Therefore, the range of acceptable values for these values is 2^31.
ID attributeEach XML schema component can have an ID attribute on it. SQL Server enforces uniqueness for <xsd:attribute> declarations of ID type, but does not store these values. The scope for enforcement of uniqueness is the {CREATE | ALTER} XML SCHEMA COLLECTION statement.
ID typeSQL Server does not support elements of type xs:ID, xs:IDREF, or xs:IDREFS. A schema may not declare elements of this type, or elements derived by restriction or extension from this type.
Local namespaceThe local namespace has to be explicitly specified for the <xsd:any> element. SQL Server rejects schemas that use an empty string ("") as a value for the namespace attribute. Instead, SQL Server requires the explicit use of "##local" to indicate an unqualified element or attribute as the instance of the wildcard character.
Mixed type and simple contentSQL Server does not support restricting a mixed type to a simple content. For more information, see Mixed Type and Simple Content.
NOTATION typeSQL Server does not support the NOTATION type.
Out-of-memory conditionsIn working with large XML schema collections, an out-of-memory condition might occur. For solutions to this problem, see Large XML Schema Collections and Out-of-Memory Conditions.
Repeated valuesSQL Server rejects schemas in which the block or final attribute has repeated values such as "restriction restriction" and "extension extension".
Schema component identifiersSQL Server limits identifiers of schema components to a maximum length of 1000 Unicode characters. Also, surrogate character pairs within identifiers are not supported.
Time zone informationIn SQL Server 2008 and later versions, time zone information is fully supported for xs:date, xs:time, and xs:dateTime values for XML Schema validation. With SQL Server 2005 backwards-compatibility mode, time zone information is always normalized to Coordinated Universal Time (Greenwich Mean Time). For elements of dateTime type, the server converts the time provided to GMT by using the offset value ("-05:00") and returning the corresponding GMT time.
Union typesSQL Server does not support restrictions from union types.
Variable precision decimalsSQL Server does not support variable precision decimals. The xs:decimal type represents arbitrary precision decimal numbers. Minimally conforming XML processors must support decimal numbers with a minimum of totalDigits=18. SQL Server supports totalDigits=38, but limits the fractional digits to 10. All xs:decimal instanced values are represented internally by the server by using the SQL type numeric (38, 10).
Canonical Forms and Pattern RestrictionsExplains canonical forms and pattern restrictions.
Wildcard Components and Content ValidationDescribes the limitations of using wildcard characters, lax validation, and anyType Elements with XML schema collections.
The <xsd:redefine> ElementExplains the limitation of using the <xsd:redefine> element and describes a workaround.
The xs:QName TypeDescribes the limitation regarding the xs:QName type.
Values for <xsd:simpleType> DeclarationsDescribes the restrictions that are applied to <xsd:simpleType> declarations.
Enumeration FacetsDescribes the limitation regarding enumeration facets.
Mixed Type and Simple ContentDescribes the limitation on restricting a mixed type to a simple content.
Large XML Schema Collections and Out-of-Memory ConditionsProvides solutions for the out-of-memory condition that sometimes occurs with large schema collections.
Non-Deterministic Content ModelsDescribes the limitations regarding non-deterministic content models.

XML Data (SQL Server)
Compare Typed XML to Untyped XML
Grant Permissions on an XML Schema Collection
Unique Particle Attribution Constraint
XML Schema Collections (SQL Server)

Community Additions