Xml验证错误根据其数据类型';版权所有';-枚举约束失败
本文关键字:版权所有 枚举 约束 失败 验证 错误 数据类型 Xml | 更新日期: 2023-09-27 18:30:04
我正在尝试验证Xml文件
我的xsd模式片段:
<xs:attribute name="PostIndex" use="optional">
<xs:annotation>
<xs:documentation>Post Index</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="6"/>
<xs:pattern value="'d{0}|'d{6}"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
XML文件片段:
<Atr1>
<Atr2 Atr="A9F130BE-3974-4698-B9F9-72037BC0E97F" PostIndex="123456" />
<Atr2 Atr3="123" Atr4="11111" />
</Atr1>
当我运行验证代码时,它通过了模式验证我有错误:
"PostIndex"属性无效-值"123456"无效根据其数据类型"String"-枚举约束失败。
这是我使用的XSD和XML,它运行良好。因此,请发布您的整个XSD和XML
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="computer">
<xs:annotation>
<xs:documentation xml:lang="it-IT">Definizione di un computer</xs:documentation>
<xs:documentation xml:lang="en-US">Definition of a computer</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:attribute name="PostInt">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="6"/>
<xs:pattern value="'d{0}|'d{6}"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
XML
<computer PostInt="123456" />
我使用了以下在线验证器