배경 :Java 구현은 SchemaFactory를 통해 RELAX NG 유효성 검사를 구현하지 않아도됩니까?
내가 가지고 NG 스키마와 스키마를 따르도록 해야하는 몇 XML 파일을 진정. 나는 자바에서 스키마에 XML 파일의 유효성을 검사하기 위해 노력하고있어 나는 오류 받고 있어요 : 나는이 같은 문제와 this post과 답변 중 하나라고 발견했습니다
No SchemaFactory that implements the schema language specified by: http://relaxng.org/ns/structure/1.0 could be loaded
을
Java implementations are not required to implement RELAX NG validation via SchemaFactory. So even if it works in one environment, it is not portable...
질문 :
이 the Jing library 같은 것들에 의존하지 않고 NG 진정 내가 휴대용 검사기를 만들 수 없다는 사실인가요?
내 응용 프로그램에서 외부 라이브러리 사용을 피하려고합니다. 자바
확인 :
...
DocumentBuilderFactory builder = DocumentBuilderFactory.newInstance();
builder.setNamespaceAware(true);
SchemaFactory schfactory = SchemaFactory.newInstance(XMLConstants.RELAXNG_NS_URI);
Schema schema = schfactory.newSchema(new File("Configuration/Schema.rng"));
builder.setSchema(schema);
Validator validator = schema.newValidator();
DocumentBuilder build = builder.newDocumentBuilder();
Document doc = build.parse(new File(filepath));
DOMSource source = new DOMSource(doc);
validator.validate(source);
...