Bonjour,

J'ai un soucis que je n'arrive pas a résoudre.
Je voudrais valider une fichier xml avec un fichier dtd externe en java.
Voici mon code:
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
public Document getDocument(String path, String dtdPath){
        Document document = null;
        DocumentType docType;
        File xml = new File(path);
        File dtd = new File(dtdPath);
        try{
            if(xml.exists()){
                if(dtd.exists()){
                    document = _DBuilder.parse(new File(path));
                }else{
                    throw new MyException(
                            "Le fichier " + dtdPath + " n'existe pas", ExceptionElements.FICHIERMANQUANT);
                }
            }else{
                throw new MyException(
                        "Le fichier " + path + " n'existe pas", ExceptionElements.FICHIERMANQUANT);
            }
        }catch(SAXException sae){
            System.out.println("SAXEception, Erreur, GetDocument, XmlUtils : " + sae);
        }catch(IOException ioe){
            System.out.println("IOException, Erreur, GetDocument, XmlUtils : " + ioe);
        }
        return document;
    }
Comme je n'ai pas de doctype de renseigner dans mes fichier xml j'aimerai trouver un moyen d'imposer un fichier dtd pour la validation.
Est-ce que quelqu'un peut m'aider?

Merci d'avance.

Pierre