XML이 아닌 XSD 파일의 유효성을 검사하고 싶습니다. 내가 사용하고있는 접근법은 다른 XML 파일로 XSD를 처리하고이 www.w3.org/2001/XMLSchema.xsd을 스키마로 사용하는 것입니다.XSD 파일 유효성 검사
String schemaLang = "http://www.w3.org/2001/XMLSchema";
SchemaFactory factory = SchemaFactory.newInstance(schemaLang);
Schema schema = factory.newSchema(new StreamSource("C:\\Users\\aprasad\\Desktop\\XMLSchema.xsd"));
Validator validator = schema.newValidator();
validator.validate(new StreamSource("shiporder.xsd"));
을하지만 난 다음 오류가 점점 오전 :
나는 다음과 같은 코드를 사용하고 오류가 파일 경로가 올바른지로 무엇
Failed to read schema document 'XMLSchema.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not
<xsd:schema>
.
확실하지.
XSD 파일의 유효성을 검사하는 올바른 방법을 알려주십시오.
스키마의 유효성을 검사하는 데 문제가 없습니다.오류 메시지가 말하는 것처럼 프로그램은'XMLSchema.xsd'를 읽을 수 없습니다. 자신의 스키마를 검증하는 것만으로는 충분하지 않습니다. 프로그램의 처음 세 줄은 다음 2 줄을 걱정하기 전에 수정해야합니다. 'shiporder.xsd' 스키마는 질문과 관련이 없습니다. – skaffman
@skaffman - 처음 3 줄에 어떤 수정이 필요한지 말할 수 있습니까? 나는 코드 @ java2s.com을 가지고있다 – Anand
스키마를 읽는 한, 스키마는 w3c에서 다운로드되고 그 이후에는 변경되지 않는다. – Anand