1

我正在尝试验证传入的 XML。XML 有一个属性verb=""。XSD 有一个可能的动词值的枚举,它不包括""选项:

<xsd:attribute name="verb" use="required">
    <xsd:simpleType>
        <xsd:restriction base="xsd:NMTOKEN">
            <xsd:enumeration value="Create" />
            <xsd:enumeration value="Delete" />
            <xsd:enumeration value="Retrieve" />
            <xsd:enumeration value="RetrieveByContent" />
            <xsd:enumeration value="Update" />
        </xsd:restriction>
    </xsd:simpleType>
</xsd:attribute>

我试图添加<xsd:enumeration value="" />,但没有奏效。谁能帮我修复 XSD?

提前致谢。

4

1 回答 1

2

您应该使用xsd:string(或xsd:token任何更有意义的)作为基础而不是xsd:NMTOKEN. xsd:NMTOKENxsd:NMTOKENS是为了与 DTD 兼容而提供的。

于 2012-08-08T14:20:49.750 回答