Bonjour,
je souhaite faire valider une instance xml par un xsd.
J'utilise le code suivant :
(trouver sur http://java.sun.com/j2se/1.5.0/docs/...e-summary.html)
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
 
 
 try {
// parse an XML document into a DOM tree
    DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    Document document = parser.parse(new File("instance.xml"));
 
    // create a SchemaFactory capable of understanding WXS schemas
    SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
 
    // load a WXS schema, represented by a Schema instance
    Source schemaFile = new StreamSource(new File("mySchema.xsd"));
    Schema schema = factory.newSchema(schemaFile);
 
    // create a Validator instance, which can be used to validate an instance document
    Validator validator = schema.newValidator();
 
    // validate the DOM tree
 
        validator.validate(new DOMSource(document));
    } catch (SAXException e) {
        // instance document is invalid!
    }
Je créé un xsd, et un xml valide vis à vis de cet xsd : tout marche bien
puis j’insère dans mon xml différentes erreurs pour voir comment cela réagit.

Des exceptions apparaissent et dans le "catch" je n'obtiens que la premiere erreur rencontrée.

Comment faire pour obtenir toutes les erreurs de mon xml d'un coup.

je vous remercie