Dilanka M
Dilanka M

Reputation: 382

How to resolve cvc-pattern-valid: Value '' is not facet-valid with respect to pattern problem

I am trying to read xsd file and its throwing below exception:

cvc-pattern-valid: Value '' is not facet-valid with respect to pattern '[1-2][0-9]{3,3}(((0[1-9])|(1[0-2]))((0[1-9])|([0-2][0-9]|3[0-1])(([0-1][0-9]|2[0-3])([0-5][0-9]([0-5][0-9](\.[0-9]{1,4})?)?)?)?)?)?([+\-](0[0-9]|1[0-3])([0-5][0-9]))?' for type '#AnonType_valueTS'.

    final Schema schema = schemaFactory.newSchema(this.getClass().getClassLoader().getResource("/schemaorg_apache_xmlbeans/src/mySchema.xsd"));
      final Validator validator = schema.newValidator();
      final StreamSource xmlFile = new StreamSource(new ByteArrayInputStream(xmlString.getBytes("utf-8")));
      validator.validate(xmlFile);

This validator.validate(xmlFile) part is throwing exception.

Any Idea? Appreciate your kind help here.

and I have already looked in to below: Value is not facet-valid with respect to pattern

Validating xml. Get the element name that throws cvc-enumeration-valid

Upvotes: 3

Views: 31006

Answers (1)

kjhughes
kjhughes

Reputation: 111601

Your XSD specifies that Value must match a specified regular expression that does not allow an empty string.

Either change Value to be a non-empty value that conforms to the XSD's regex, or change the regex to allow an empty string.

Upvotes: 5

Related Questions