xs:dateTime和xs:string的并集



我在XSD中使用以下格式来接受标记的字符串和日期时间格式

<xs:simpleType name="dateTime-or-string">
    <xs:union memberTypes="xs:dateTime xs:string"/>
</xs:simpleType>
<xs:complexType  name="CustomDate">
            <xs:simpleContent>
                <xs:extension base="dateTime-or-string">
                    <xs:attribute name="nullable" type="xs:string" />
                </xs:extension>
            </xs:simpleContent>
</xs:complexType>
<xs:element name="StartDate" type="CustomDate">

如果不正确,请提供帮助。

我的标签是这样的:

<lastdate nullable="true"/> or <lastdate>2015-08-05+02:00</lastdate>

由于xs:dateTimexs:string的严格子集,因此不需要将这两种类型联合在一起。您可以单独使用xs:string

最新更新