Bonjour,
J'aimerais valider un fichier XML a partir d'un fichier XSD que j'aurais déjà sur l'ordinateur.
J'ai trouvé plusieurs exemples mais aucun ne fonctionne chez moi, il y a toujours un problème, soit les packages ne sont pas bon et je ne trouve pas exactement les bon, soit j'ai des problèmes de :
SAX property 'http://java.sun.com/xml/jaxp/properties/schemaLanguage' not recognized
Exemple ce code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| * static final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
*
* static final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
*
* static final String JAXP_SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";
*
* // Pour DOM
* DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
* dbf.setIgnoringComments(true);
* dbf.setNamespaceAware(true);
* dbf.setValidating(true);
* dbf.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
* dbf.setAttribute(JAXP_SCHEMA_SOURCE, new File(xsdFile));
*
* // Pour SAX
* SAXParserFactory spf = SAXParserFactory.newInstance();
* spf.setNamespaceAware(true);
* spf.setValidating(true);
* SAXParser sp = spf.newSAXParser();
* sp.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
* sp.setProperty(JAXP_SCHEMA_SOURCE, xsdFile);
*
* Pour le reste du code : in the zip ! |
chez moi qui ne fonctionne pas a cause des property not recognized...
Bref, si quelqu'un peut m'aider ?
Merci
++
Partager