XSD:允许空字符串的XML验证

时间:2014-10-10 08:26:26

标签: xml xsd

<xs:element name="SpouseVisionPlanExist" nillable="true" minOccurs="0">
                            <xs:simpleType>
                                <xs:union memberTypes="EmptyStrings Int"/>
                            </xs:simpleType>
                        </xs:element>

<xs:simpleType name="EmptyStrings">
    <xs:restriction base="xs:string">
        <xs:enumeration value=""/>
    </xs:restriction>
</xs:simpleType>
<xs:simpleType name="Int">
    <xs:restriction base="xs:string">
        <xs:pattern value="[01]"/>
    </xs:restriction>
</xs:simpleType>

如果我提供空值

<SpouseVisionPlanExist></SpouseVisionPlanExist>

我收到验证错误。它说,&#34;&#39; SpouseVisionPlanExist&#39;元素无效 - 值&#39;     &#39;根据其数据类型&#39; Union&#39; - 价值&#39;     &#39;根据联盟的任何memberTypes无效。&#34;

0 个答案:

没有答案
相关问题