所以我在编写 XML 时遇到了这个恼人的错误。错误描述:
cvc-enumeration-valid:值“First”对于枚举“[First, Second]”而言无效。它必须是枚举中的值。
架构
<xs:simpleType name="std-semester">
<xs:restriction base="xs:string">
<xs:enumeration value="First"/>
<xs:enumeration value="Second"/>
</xs:restriction>
</xs:simpleType>
正如您所看到的,枚举值是 First 和 Second,但即使我输入正确的值“First”,仍然会出现上述错误。是什么赋予了?
最佳答案
“First”中的尾随空格很重要。如果您希望将前导空格和尾随空格视为无关紧要,请使用类型 xs:NMTOKEN 而不是 xs:string。
关于XML 无效枚举,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16787550/