SQL Server does not support restrictions from union types per this article: https://docs.microsoft.com/en-us/sql/relational-databases/xml/requirements-and-limitations-for-xml-schema-collections-on-the-server?view=sql-server-2017
I am attempting to create a schema collection from a supplied XSD that contains such and (as expected) receive this error:
XML Validation: Invalid definition for type '{ http://www.mismo.org/residential/2009/schemas}MISMODate_Base'. SQL Server does not currently support restriction of union types.
I've been able to create the schema collection if I modify the XSD to remove the union type restriction, however I'd like to know if there is a way I can represent the intended restrictions (see below) in a way that SQL Server supports:
<xsd:simpleType name="MISMODate_Base"> <xsd:restriction base="MISMODate_Union"> <xsd:pattern value="[0-9]{4}([\-][0-9]{2}){0,2}([Z]|(([+]|[\-])[0-9]{2}[:][0-9]{2}))?"/> </xsd:restriction> </xsd:simpleType> <xsd:simpleType name="MISMODate_Union"> <xsd:union memberTypes="xsd:gYear xsd:gYearMonth xsd:date"/> </xsd:simpleType>
Ideally the MISMODate_Base type would retain the multiple restriction bases from the MISMODate_Union type...being a novice with XSD construction I welcome any suggestions.