[dom4j & Xerces] How to show validation errors?

S

Stefan Siegl

Hello

I am using the dom4j API which will use the Xerces2 SAX Parser. I set
this Parser to use validation. The problem I face is, that I need to
know what exactly went wrong during the check for well-formedness resp.
the validation check.

If _anything_ went wrong, meaning either a well-formed error or a
validation error, a DocumentException is thrown, containing no
inforamtion about what went wrong.

In my application (in fact it is a servlet) I will receive xml files. If
they are not valid I have to return the information what went wrong.

Do you know of any possiblity?

Here is my code so far:

public Document buildDocument () throws DocumentException,
SAXException{

Document doc = null;
SAXReader reader = new
SAXReader("org.apache.xerces.parsers.SAXParser",true);

reader.setFeature("http://xml.org/sax/features/namespaces",true);
reader.setFeature("http://xml.org/sax/features/validation",true);

reader.setFeature("http://apache.org/xml/features/validation/schema",true);

DocumentFactory factory = reader.getDocumentFactory();
doc = reader.read(stream);

return doc;
}

Thanks in advance,
Stefan Siegl
 
S

Stefan Siegl

Stefan Siegl wrote:

Sorry, I found the problem. Every time I post my problems here, a few
seconds later I will find it myself.

Please ignore this message :)
 
D

David Zimmerman

Stefan said:
Stefan Siegl wrote:

Sorry, I found the problem. Every time I post my problems here, a few
seconds later I will find it myself.

Please ignore this message :)
Seems to be related to the Murphy's law about lost tools.
The best way to find a lost tool is to buy a new one.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,833
Latest member
BettyeMacf

Latest Threads

Top