【发布时间】:2018-03-24 00:02:34
【问题描述】:
我的 XSD 中有这个:
<xs:element name="End_Date" type="xs:date" minOccurs="0"/>
如果有日期或有空节点,我想要验证通过
<End_Date>2011-05-31T00:00:00.000</End_Date>
应该没问题
<End_Date></End_Date>
如何修改 XSD 以使其如此?
我尝试了不同的方法:
nillable="true"
和
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"
和
<xs:element name="End_Date">
<xs:simpleType>
<xs:union memberTypes="xs:date">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value=""/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
</xs:element>
它们都不起作用。
错误:
检测到错误:“xxxxxxxxxx:End_Date”元素无效 - 值 '' 根据其数据类型无效 'http://www.w3.org/2001/XMLSchema:date' - 字符串 '' 无效 XsdDateTime 值。
【问题讨论】: