如何解决 cvc-pattern-valid: Value '' is not facet-valid 就模式问题而言

Dil*_*a M 3 java xml xsd sax

我正在尝试读取xsd文件及其抛出如下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);
Run Code Online (Sandbox Code Playgroud)

这个validator.validate(xmlFile)部分正在抛出exception.

任何想法?在此感谢您的帮助。

我已经查看了下面的内容: 值对于模式而言不是侧面有效的

验证 xml。获取抛出 cvc-enumeration-valid 的元素名称

kjh*_*hes 5

您的 XSD 指定Value必须匹配不允许空字符串的指定正则表达式。

更改Value为符合 XSD 正则表达式的非空值,或者更改正则表达式以允许空字符串。