我想讀xsd
文件及其投擲下面exception
:CVC圖案有效:值「」不是刻面的有效相對於模式
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);
這validator.validate
(XMLFILE)部分被投擲exception
。
任何想法?在此感謝您的善意幫助。
,我已經看了看下面: Value is not facet-valid with respect to pattern
Validating xml. Get the element name that throws cvc-enumeration-valid
如果沒有看到架構和源文檔,就無法說明您的XML源無效的原因。但是有一點關於你的代碼:如果你在一個字符串xmlStr中有XML源代碼,最好是用新的StreamSource(新的StringReader(xmlStr))而不是通過一個字節數組來執行 - 你冒着風險編碼問題。 –