在服务器上使用 XML 架构集合的要求和限制Requirements and Limitations for XML Schema Collections on the Server

适用于:Applies to: 是SQL ServerSQL Server(所有支持的版本)yesSQL ServerSQL Server (all supported versions) 是Azure SQL 数据库Azure SQL DatabaseYesAzure SQL 数据库Azure SQL Database适用于:Applies to: 是SQL ServerSQL Server(所有支持的版本)yesSQL ServerSQL Server (all supported versions) 是Azure SQL 数据库Azure SQL DatabaseYesAzure SQL 数据库Azure SQL Database

XML 架构定义语言 (XSD) 验证对使用 xml 数据类型的 SQL 列具有某些限制。The XML schema definition language (XSD) validation has some limitations regarding SQL columns that use the xml data type. 下表提供有关这些限制的详细信息,还提供了修改 XSD 架构的准则以使它可以与 SQL ServerSQL Server一起使用。The following table provides details about those limitations and guidelines for modifying your XSD schema so it can work with SQL ServerSQL Server. 本部分中的主题提供有关使用这些特定限制和准则的其他信息。The topics in this section provide additional information about specific limitations and guidance for working with them.

ItemItem 限制Limitation
minOccursmaxOccursminOccurs and maxOccurs minOccursmaxOccurs 属性的值必须符合 4 字节整数。The 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 ServerSQL Server 拒绝具有包含无子级的 <xsd:choice> 粒子的架构,除非该粒子的 minOccurs 属性值定义为零 。rejects schemas that have an <xsd:choice> particle without children, unless the particle is defined with a minOccurs attribute value of zero.
<xsd:include> 当前, SQL ServerSQL Server 不支持此元素。Currently, SQL ServerSQL Server does not support this element. 服务器拒绝包含此元素的 XML 架构。XML schemas that include this element are rejected by the server.

解决方案是可以预处理包括 <xsd:include> 指令的 XML 架构,以将任何包括的架构的内容复制并合并到单个架构,以便上传到服务器。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> 和 <xsd:unique> <xsd:key>, <xsd:keyref>, and <xsd:unique> 当前, SQL ServerSQL Server 不支持这些用于强制唯一性或建立键和键引用的基于 XSD 的约束。Currently, SQL ServerSQL Server does not support these XSD-based constraints for enforcing uniqueness or establishing keys and key references. 无法注册包含这些元素的 XML 架构。XML schemas that contain these elements cannot be registered.
<xsd:redefine> SQL ServerSQL Server 不支持此元素。does not support this element. 有关更新架构的其他方法的信息,请参阅 <xsd: redefine> 元素一起使用。For information about another way to update schemas, see The <xsd:redefine> Element.
<xsd:simpleType> 值<xsd:simpleType> values SQL ServerSQL Server 对带有除 xs:timexs:dateTime以外的秒部分的简单类型仅支持毫秒精度,对 xs:timexs:dateTime则支持 100 纳秒精度。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 ServerSQL Server 对所有已识别的 XSD 简单类型枚举具有限制。puts limitations on all recognized XSD simple type enumerations.

SQL ServerSQL Server 不支持在 <xsd:simpleType> 声明中使用“NaN”值。does not support using the "NaN" value in <xsd:simpleType> declarations.

有关详细信息,请参阅xsd:simpleType 声明的值一起使用。For more information, seeValues for <xsd:simpleType> Declarations.
xsi:schemaLocationxsi:noNamespaceSchemaLocationxsi:schemaLocation and xsi:noNamespaceSchemaLocation SQL ServerSQL Server 如果在插入到 xml 数据类型的列或变量的 XML 实例数据中存在这些属性,则将忽略这些属性。ignores these attributes if they are present in the XML instance data inserted into a column or variable of xml data type.
xs:QNamexs:QName SQL ServerSQL Server 不支持从 xs:QName 派生的使用 XML 架构限制元素的类型。does not support types derived from xs:QName that use an XML Schema restriction element.

SQL ServerSQL Server 不支持将 xs:QName 作为成员元素的联合类型。does not support union types with xs:QName as a member element.

有关详细信息,请参阅 The xs:QName TypeFor more information, see The xs:QName Type.
将成员添加到现有替换组Adding members to an existing substitution group 无法将成员添加到 XML 架构集合中的现有替换组。You cannot add members to an existing substitution group in an XML schema collection. XML 架构中的替换组有以下限制:头元素和所有其成员元素必须在相同的 {CREATE | ALTER} 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 restrictions 值的规范表示形式不能违反其类型的模式限制。The canonical representation of a value cannot violate the pattern restriction for its type. 有关详细信息,请参阅 Canonical Forms and Pattern RestrictionsFor more information, see Canonical Forms and Pattern Restrictions.
枚举方面Enumeration facets SQL ServerSQL Server 不支持包含以下类型的 XML 架构:具有模式方面或违反这些方面的枚举的类型。does not support XML schemas with types that have pattern facets or enumerations that violate those facets.
方面长度Facet length lengthminLengthmaxLength 方面作为 long 类型存储。The length, minLength, and maxLength facets are stored as a long type. 此类型为 32 位类型。This type is a 32-bit type. 因此,这些值的可接受值的范围是 2^31。Therefore, the range of acceptable values for these values is 2^31.
ID 属性ID attribute 每个 XML 架构组件可在其上具有 ID 属性。Each XML schema component can have an ID attribute on it. SQL ServerSQL Server 对 ID 类型的 <xsd:attribute> 声明强制唯一性,但不存储这些值 。enforces uniqueness for <xsd:attribute> declarations of ID type, but does not store these values. 唯一性的强制的作用范围是 {CREATE | ALTER} XML SCHEMA COLLECTION 语句。The scope for enforcement of uniqueness is the {CREATE | ALTER} XML SCHEMA COLLECTION statement.
ID 类型ID type SQL ServerSQL Server 不支持类型为 xs:IDxs:IDREFxs:IDREFS的元素。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 namespace 必须为 <xsd:any> 元素显式指定本地命名空间。The local namespace has to be explicitly specified for the <xsd:any> element. SQL ServerSQL Server 拒绝使用空字符串 ("") 作为命名空间属性的值的架构。rejects schemas that use an empty string ("") as a value for the namespace attribute. SQL ServerSQL Server 而是要求显式使用“##local”以指示作为通配符实例的未限定元素或属性。Instead, SQL ServerSQL 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 content SQL ServerSQL Server 不支持将混合类型限制为简单内容。does not support restricting a mixed type to a simple content. 有关详细信息,请参阅 Mixed Type and Simple ContentFor more information, see Mixed Type and Simple Content.
NOTATION 类型NOTATION type SQL ServerSQL Server 不支持 NOTATION 类型。does not support the NOTATION type.
内存不足的情况Out-of-memory conditions 在使用大型 XML 架构集合时,可能会出现内存不足的情况。In working with large XML schema collections, an out-of-memory condition might occur. 有关此问题的解决方案,请参阅 大型 XML 架构集合和内存不足的情况For solutions to this problem, see Large XML Schema Collections and Out-of-Memory Conditions.
重复的值Repeated values SQL ServerSQL Server 拒绝其中的 block 或 final 属性具有重复值(如“restriction restriction”和“extension extension”)的架构。rejects schemas in which the block or final attribute has repeated values such as "restriction restriction" and "extension extension".
架构组件标识符Schema component identifiers SQL ServerSQL Server 将架构组件的标识符限于最大长度为 1000 个 Unicode 字符。limits identifiers of schema components to a maximum length of 1000 Unicode characters. 另外,不支持在标识符中使用代理项字符对。Also, surrogate character pairs within identifiers are not supported.
时区信息Time zone information SQL Server 2008SQL Server 2008 和更高版本中,完全支持进行 XML 架构验证的 xs:datexs:timexs:dateTime 值的时区信息。In SQL Server 2008SQL Server 2008 and later versions, time zone information is fully supported for xs:date, xs:time, and xs:dateTime values for XML Schema validation. 通过 SQL Server 2005 (9.x)SQL Server 2005 (9.x) 向后兼容模式,始终将时区信息规范化为协调世界时(格林尼治标准时间)。With SQL Server 2005 (9.x)SQL Server 2005 (9.x) backwards-compatibility mode, time zone information is always normalized to Coordinated Universal Time (Greenwich Mean Time). 对于 dateTime 类型的元素,服务器将通过使用偏移值(“-05:00”)和返回相应的 GMT 时间转换提供给 GMT 的时间。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 types SQL ServerSQL Server 不支持联合类型的限制。does not support restrictions from union types.
可变精度小数Variable precision decimals SQL ServerSQL Server 不支持可变精度小数。does not support variable precision decimals. xs:decimal 类型表示任意精度十进制数字。The xs:decimal type represents arbitrary precision decimal numbers. 最小符合 XML 处理器必须支持最小值为 totalDigits=18的十进制数字。Minimally conforming XML processors must support decimal numbers with a minimum of totalDigits=18. SQL ServerSQL Server 支持 totalDigits=38, ,但将小数位数限制为 10。supports totalDigits=38, but limits the fractional digits to 10. 所有 xs:decimal 实例化的值均由服务器通过使用 SQL 类型数值 (38, 10) 在内部表示。All xs:decimal instanced values are represented internally by the server by using the SQL type numeric (38, 10).

本节内容In This Section

主题Topic 说明Description
规范格式和模式限制Canonical Forms and Pattern Restrictions 说明规范格式和模式限制。Explains canonical forms and pattern restrictions.
通配符组成部分和内容验证Wildcard Components and Content Validation 介绍了使用通配符、宽松验证和任何带有 XML 架构集合的类型元素的限制。Describes the limitations of using wildcard characters, lax validation, and anyType Elements with XML schema collections.
<xsd: redefine> 元素The <xsd:redefine> Element 说明使用 <xsd:redefine> 元素的限制并介绍了解决方法。Explains the limitation of using the <xsd:redefine> element and describes a workaround.
xs:QName 类型The xs:QName Type 介绍与 xs:QName 类型有关的限制。Describes the limitation regarding the xs:QName type.
xsd:simpleType 声明的值Values for <xsd:simpleType> Declarations 介绍了 <xsd:simpleType> 声明适用的限制。Describes the restrictions that are applied to <xsd:simpleType> declarations.
枚举分面Enumeration Facets 介绍与枚举方面有关的限制。Describes the limitation regarding enumeration facets.
混合类型和简单内容Mixed Type and Simple Content 介绍将混合类型限制为简单内容的限制。Describes the limitation on restricting a mixed type to a simple content.
大型 XML 架构集合和内存不足的情况Large XML Schema Collections and Out-of-Memory Conditions 提供在大型架构集合有时发生内存不足时的解决方案。Provides solutions for the out-of-memory condition that sometimes occurs with large schema collections.
不确定性内容模型Non-Deterministic Content Models 介绍与不确定性内容模型有关的限制。Describes the limitations regarding non-deterministic content models.

另请参阅See Also

XML 数据 (SQL Server) XML Data (SQL Server)
类型化的 XML 与非类型化的 XML 的比较 Compare Typed XML to Untyped XML
授予对 XML 架构集合的权限 Grant Permissions on an XML Schema Collection
唯一粒子归属约束 Unique Particle Attribution Constraint
XML 架构集合 (SQL Server)XML Schema Collections (SQL Server)