I'm trying to validate an incoming XML. The XML has an attribute verb="". The XSD has an enumeration of the possible verb values and it doesn't include the "" option:
我正在尝试验证传入的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>
I tried to add <xsd:enumeration value="" />
but it didn't work. Can anyone help me with fixing the XSD?
我试图添加
Thanks in advance.
提前致谢。
1 个解决方案
#1
1
You should use xsd:string
(or xsd:token
whichever makes more sense) as the base instead of xsd:NMTOKEN
. xsd:NMTOKEN
, xsd:NMTOKENS
etc are provided for compatibility with DTD.
您应该使用xsd:string(或xsd:token,更有意义)作为基础而不是xsd:NMTOKEN。 xsd:NMTOKEN,xsd:NMTOKENS等是为了与DTD兼容而提供的。
#1
1
You should use xsd:string
(or xsd:token
whichever makes more sense) as the base instead of xsd:NMTOKEN
. xsd:NMTOKEN
, xsd:NMTOKENS
etc are provided for compatibility with DTD.
您应该使用xsd:string(或xsd:token,更有意义)作为基础而不是xsd:NMTOKEN。 xsd:NMTOKEN,xsd:NMTOKENS等是为了与DTD兼容而提供的。