[dom4j & Xerces] How to show validation errors?

Discussion in 'Java' started by Stefan Siegl, Jul 17, 2003.

  1. Stefan Siegl

    Stefan Siegl Guest

    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
    Stefan Siegl, Jul 17, 2003
    #1
    1. Advertising

  2. Stefan Siegl

    Stefan Siegl Guest

    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 :)
    Stefan Siegl, Jul 17, 2003
    #2
    1. Advertising

  3. Stefan Siegl wrote:
    > 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.
    David Zimmerman, Jul 17, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wolfgang
    Replies:
    0
    Views:
    630
    Wolfgang
    Jul 9, 2003
  2. Cram TeXeD
    Replies:
    1
    Views:
    353
    Cram TeXeD
    Feb 2, 2004
  3. Ewan B
    Replies:
    0
    Views:
    553
    Ewan B
    Sep 26, 2003
  4. Grand Apeiron
    Replies:
    7
    Views:
    1,729
    Peter Flynn
    Jan 20, 2004
  5. cvissy
    Replies:
    0
    Views:
    601
    cvissy
    Nov 16, 2004
Loading...

Share This Page