Which DocumentBuilderFactory are you using, because I get a
DocumentBuilderFactory configurationError when I call new instance. 

Erik

-----Original Message-----
From: Heinerman Robert [mailto:[EMAIL PROTECTED]]
Sent: dinsdag 23 oktober 2001 15:26
To: '[EMAIL PROTECTED]'
Subject: AW: Validating XML with Xerces


hi

thats our read method which works:

public static Document read(File inFile,boolean vali,boolean nami) 
   throws
eRSystemXMLParseException,eRSystemIOException,eRSystemIllegalArgumentExcepti
on,eRSystemXMLInvalidFileException
  {
    DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();
    dbf.setValidating(vali); dbf.setNamespaceAware(nami);
    DocumentBuilder db=null;
    try{
      db=dbf.newDocumentBuilder();
    } catch(javax.xml.parsers.ParserConfigurationException ex){throw new
eRSystemXMLParseException(inFile.toString(),ex.getMessage());}
    Document doc=null;
    try {
      doc=db.parse(inFile);
    } catch (SAXParseException spe) {
       // Error generated by the parser
       throw new eRSystemXMLInvalidFileException(inFile.toString(),"Parse
Error in line :"+spe.getLineNumber());

    }catch(SAXException se){
        throw new eRSystemXMLParseException(inFile.toString(),"SAXException
occured: "+se.getMessage());
    }catch(IOException ioe){
        throw new eRSystemIOException("IOException for File :"+
inFile.getPath()+" occured");
    }catch(IllegalArgumentException iae) {
         throw new
eRSystemIllegalArgumentException("IllegalArgumentException:
"+iae.getMessage());
    }
    return(doc);
  }

the method of DocumentBuilderFactory, setValidating(boolean) configures the
parser that it throws an exception if the xml file is not valid.

rob


     \|/                           _________
     -O-                     _____/
     /|\             _______/
~~~~~~~~~~~~~~~~~~~~/
Dipl. Ing. (FH) Robert Heinerman
Siemens PSE BS MT2, Gudrunstr. 11, 1100 Wien
+43 51707 47383, [EMAIL PROTECTED] 
 


-----Urspr�ngliche Nachricht-----
Von: Kazandjian Erik [mailto:[EMAIL PROTECTED]]
Gesendet am: Dienstag, 23. Oktober 2001 15:05
An: '[EMAIL PROTECTED]'
Betreff: Validating XML with Xerces

Hello,

I'm trying to parse an XML document with a DOMparser and validate it against
a DTD (wich is included in my XML). I have try ti set serveral deatures on
my DOMParser but the parser dos not seem to find any errors in my XML even
if I put errors in it. What can I do about it ?

Erik


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

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

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

Reply via email to