Bonjour et bonnes fêtes
J'ai un probleme quand je valide un instance XML avec un schéma XSD:
===>src-resolve: Cannot resolve the name 'ReqDoc' to a(n) 'type definition' component.
Avec ce morceau de code
Pourtant, j'arrive à générer les classes Java à partir de ce schéma avec xjc.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 public void validatorV1() { try { // define the type of schema - we use W3C: String schemaLang = "http://www.w3.org/2001/XMLSchema"; // get validation driver: SchemaFactory factory = SchemaFactory.newInstance(schemaLang); // create schema by reading it from an XSD file: Schema schema = factory.newSchema(new File("C:/Tmp/XmlSchemes/my_instance.xsd")); Validator validator = schema.newValidator(); Source source = new SAXSource(new InputSource("C:/Tmp/Response/result.xml")); // at last perform validation: validator.setErrorHandler(new ErrorHandler()); validator.validate(source); } catch (SAXException e) { // we are here if the document is not valid: // ... process validation error... System.err.println("===>Error validation " + e.getMessage()); } catch (IOException e) { e.printStackTrace(); } }
Pouvez-vous me dire comment fixer cette erreur?
Merci d'avance
Partager