question

sbowden81 avatar image
sbowden81 asked

Creating SQL schema collection from XSD with union type restrictions

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.

xmlschemaxsd
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

· Write an Answer

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.