2014-07-22 2 views
0

배경 :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); 

     ... 

답변

0

네, 사실입니다. 필자가 아는 바로는 W3C에서 정의한 XML 스키마가 유일하게 이식 가능한 스키마 언어이다. RELAX NG는 일반 XML 스키마를 뛰어 넘는 추가 기능을 제공합니다.

0

IBM Post은 내 질문을 명확히했습니다.

Out of the box, the JDK doesn't include a RELAX NG validator.