Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cvc-enumeration-valid: Value '2' is not facet-valid with respect to enumeration '[1]'. It must be a value from the enumeration

I am getting error validating with this XML:

XSD

<xs:simpleType name="XYZ">
    <xs:restriction base="xs:nonNegativeInteger">
      <xs:enumeration value="1">
      </xs:enumeration>
      <xs:enumeration value="2">
      </xs:enumeration>
    </xs:restriction>
  </xs:simpleType>

XML value :

 <XYZ>2</XYZ>

Error

cvc-enumeration-valid: Value '2' is not facet-valid with respect to enumeration '[1]'. It must be a value from the enumeration.

Can anyone please help me to understand the problem? How to resolve it ?

like image 203
Ramesh Avatar asked Sep 20 '25 00:09

Ramesh


1 Answers

The error message,

cvc-enumeration-valid: Value '2' is not facet-valid with respect to enumeration '[1]'. It must be a value from the enumeration.

and the simpleType from your question do not agree.

The error message implies that only 1 is allowed yet 2 was encountered; your type definition does indeed allow both 1 and 2.

To elicit an actual error message pertaining to your xs:simpleType, your XML would have to use a value, say 3, not allowed. Then, you would receive an error message like this:

cvc-enumeration-valid: Value '3' is not facet-valid with respect to enumeration '[1, 2]'. It must be a value from the enumeration.

Therefore, your (first, maybe only?) mistake is in believing that the posted xs:simpleType definition has anything to do with that error message.

like image 125
kjhughes Avatar answered Sep 23 '25 07:09

kjhughes