Thanks Lionel

--------
David

-----Mensaje original-----
De: Lionel Crine [mailto:[EMAIL PROTECTED]
Enviado el: lunes, 24 de noviembre de 2003 12:33
Para: [EMAIL PROTECTED]
Asunto: Re: Validating XML

I wrote an action validation an XML document according a DTD.
Here is it the main part :


DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setValidating(true);
DocumentBuilder db = null;
try {
db = dbf.newDocumentBuilder();
ErrorHandler handler = (ErrorHandler) new ValidationException();  --> this
is a custom exception (implements from ErrorHandler)
db.setErrorHandler(handler);
db.parse(new InputSource(new
ByteArrayInputStream(strDocument.getBytes("UTF-8"))));
return AbstractAction.EMPTY_MAP;
}
catch (ParserConfigurationException pce) {
Debugger.println("ValidatingDTDAction.act : Parser Configuration Exception");
pce.printStackTrace();
return null;
}
catch (SAXParseException spe) {
Debugger.println("ValidatingDTDAction.ect: SAXParser Exception Exception");
//spe.printStackTrace();
return null;
}

I think I've already posted a message about that, you should search the
archive.

Lionel


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to