jayb
21-03-2006, 17:15
Ho realizzato una funzione usando JDOM per la convalida dei file xml con i relativi schema e mi dà questo errore:
org.jdom.JDOMException: Failed to parse schema "c:/esempi/ValidaSchema/schemaes1.xsd": no validation engine available for: http://www.w3.org/2001/XMLSchema: no validation engine available for: http://www.w3.org/2001/XMLSchema
Il codice è:
public static void validate(Document document, String URIDelloSchema) throws DAOException{
try {
Schema schema = Schema.parse(URIDelloSchema, Schema.W3C_XML_SCHEMA);
System.out.println("parsing effettuato");
java.util.List errori = schema.validate(document);
if (errori != null) {
for (int i = 0; i < errori.size(); i++) {
ValidationError errore = (ValidationError) errori.get(i);
System.out.println(errore.getMessage());
}
}
}
catch (JDOMException ecc) {
throw new DAOException(ecc);
}
catch(java.io.IOException ioe){
System.out.println(ioe);
}
}
Ho notato che l'errore lo dà all'istruzione schema.validate(document).
La richiamo da un main:
public static void main(String[] args) {
try{
String path="esempio1.xml";
Document document=costruisciDOM(path);
System.out.println("DOM costruito");
String uri="c:/esempi/ValidaSchema/schemaes1.xsd";
validate(document,uri);
}catch(Exception ecc){
System.out.println(ecc);
}
}
Il document è corretto(la funzione CreaDOM l'ho testata), mentre ho un dubbio sull'uri.
Avete qualche suggerimento?
POTETE SUGGERIRMI UNA GUIDA A JDOM O UN LIBRO????
GRAZIE
org.jdom.JDOMException: Failed to parse schema "c:/esempi/ValidaSchema/schemaes1.xsd": no validation engine available for: http://www.w3.org/2001/XMLSchema: no validation engine available for: http://www.w3.org/2001/XMLSchema
Il codice è:
public static void validate(Document document, String URIDelloSchema) throws DAOException{
try {
Schema schema = Schema.parse(URIDelloSchema, Schema.W3C_XML_SCHEMA);
System.out.println("parsing effettuato");
java.util.List errori = schema.validate(document);
if (errori != null) {
for (int i = 0; i < errori.size(); i++) {
ValidationError errore = (ValidationError) errori.get(i);
System.out.println(errore.getMessage());
}
}
}
catch (JDOMException ecc) {
throw new DAOException(ecc);
}
catch(java.io.IOException ioe){
System.out.println(ioe);
}
}
Ho notato che l'errore lo dà all'istruzione schema.validate(document).
La richiamo da un main:
public static void main(String[] args) {
try{
String path="esempio1.xml";
Document document=costruisciDOM(path);
System.out.println("DOM costruito");
String uri="c:/esempi/ValidaSchema/schemaes1.xsd";
validate(document,uri);
}catch(Exception ecc){
System.out.println(ecc);
}
}
Il document è corretto(la funzione CreaDOM l'ho testata), mentre ho un dubbio sull'uri.
Avete qualche suggerimento?
POTETE SUGGERIRMI UNA GUIDA A JDOM O UN LIBRO????
GRAZIE