xml 和 xsd 的架构验证失败
Schema validation fails for xml and xsd
这是我的xsd
<xs:schema id="RCDNetworkAdapterData" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="RCDNetworkAdapterData">
<xs:complexType>
<xs:sequence>
<xs:element name="AdapterName" minOccurs="1" nillable="false" maxOccurs="3">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="3"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
这是映射到它的 xml:
<RCDNetworkAdapterData>
<AdapterName>Ethernet</AdapterName>
<AdapterName>WI-FI</AdapterName>
</RCDNetworkAdapterData>
请帮助修改 xsd 以映射到 xml 结构
使用 Saxon 作为模式验证器时,我收到错误消息:
Validation error on line 2 column 39 of test.xml:
FORG0001: The content "Ethernet" of element <AdapterName> does not match the required
simple type. Value "Ethernet" contravenes the maxLength facet "3" of the type of element AdapterName
See http://www.w3.org/TR/xmlschema-2/#cvc-datatype-valid clause 1
Validation error on line 3 column 36 of test.xml:
FORG0001: The content "WI-FI" of element <AdapterName> does not match the required simple
type. Value "WI-FI" contravenes the maxLength facet "3" of the type of element AdapterName
See http://www.w3.org/TR/xmlschema-2/#cvc-datatype-valid clause 1
希望这些消息是清楚的:您已将 AdapterName 的值限制为 1 到 3 个字符,并且您的值比这更长。
这是我的xsd
<xs:schema id="RCDNetworkAdapterData" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="RCDNetworkAdapterData">
<xs:complexType>
<xs:sequence>
<xs:element name="AdapterName" minOccurs="1" nillable="false" maxOccurs="3">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="3"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
这是映射到它的 xml:
<RCDNetworkAdapterData>
<AdapterName>Ethernet</AdapterName>
<AdapterName>WI-FI</AdapterName>
</RCDNetworkAdapterData>
请帮助修改 xsd 以映射到 xml 结构
使用 Saxon 作为模式验证器时,我收到错误消息:
Validation error on line 2 column 39 of test.xml:
FORG0001: The content "Ethernet" of element <AdapterName> does not match the required
simple type. Value "Ethernet" contravenes the maxLength facet "3" of the type of element AdapterName
See http://www.w3.org/TR/xmlschema-2/#cvc-datatype-valid clause 1
Validation error on line 3 column 36 of test.xml:
FORG0001: The content "WI-FI" of element <AdapterName> does not match the required simple
type. Value "WI-FI" contravenes the maxLength facet "3" of the type of element AdapterName
See http://www.w3.org/TR/xmlschema-2/#cvc-datatype-valid clause 1
希望这些消息是清楚的:您已将 AdapterName 的值限制为 1 到 3 个字符,并且您的值比这更长。