Why This Error Happens
This error occurs when registering an XML schema collection in SQL Server where an xsd:list element references a complex type instead of a simple type as its item type. The SQL Server XML schema validation engine strictly enforces W3C XSD rules, which mandate that list items must resolve to simple types (atomic or union types). This typically results from a malformed or manually edited XSD file, or from an XSD generated by a third-party tool that does not fully comply with the XSD 1.0/1.1 specification.
Step-by-Step Resolution Guide
Step 1: Locate and Inspect the Offending XSD File
- Identify the exact schema file referenced in the error message’s
Location: '%ls'placeholder. - Open the XSD in a validating editor (Visual Studio 2022/2025, Oxygen XML, or VS Code with the XML extension) rather than a plain text editor.
- Search for the
<xsd:list itemType="...">declaration and note the type it references.
Step 2: Correct the itemType Reference
- Verify the type referenced by
itemTypeis declared with<xsd:simpleType>and not<xsd:complexType>. - If the referenced type is complex, either redefine it as a simple type (e.g.,
<xsd:restriction base="xsd:string">) or create a new simple type and pointitemTypeto it. - Example fix:
<xsd:simpleType name="ValidItem">
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
<xsd:simpleType name="ItemList">
<xsd:list itemType="ValidItem"/>
</xsd:simpleType>
Step 3: Re-register the XML Schema Collection
- In SQL Server Management Studio (SSMS) connected to your SQL Server 2025 instance, drop the existing faulty schema collection:
DROP XML SCHEMA COLLECTION dbo.YourSchemaCollectionName;
- Re-create it using the corrected XSD file:
CREATE XML SCHEMA COLLECTION dbo.YourSchemaCollectionName
AS N'<paste corrected XSD content here>';
Step 4: Validate Dependent Objects
- Check any tables, stored procedures, or XML columns bound to this schema collection for compatibility with the updated type definitions.
- Recompile affected stored procedures using
sp_recompileif type changes impact parameter validation.
Alternative or Verification Steps
- Run
SELECT * FROM sys.xml_schema_collections WHERE name = 'YourSchemaCollectionName';to confirm the schema registered without error. - If the issue persists, validate the XSD independently using the
xmllint --schemacommand-line tool or an online XSD validator to confirm W3C compliance before re-importing it into SQL Server.