#c# #xml #xsd
#c# #xml #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
Комментарии:
1. Почему бы не помочь своим читателям, сообщив, что такое сообщение об ошибке? Чем проще вы делаете вещи, тем больше вероятность, что вы получите ответ.
Ответ №1:
С помощью 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 символов, и ваши значения длиннее этого.