You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by ne...@ca.ibm.com on 2000/12/12 17:45:03 UTC

Re: parser is not validating the xml document


Hi Asha,

The problem is that you haven't declared an ErrorHandler for your parser to
use when reporting errors.  samples/dom/wrappers/DOMWrapper.java contains a
good example of a way to do this.  By cutting and pasting the content of
this file into the same file as your Java code, and doing the appropriate
massaging, I was able to get Xerces to emit the appropriate error messages.

Hope that helps,
Neil

Neil Graham
XML Parser Development
IBM Toronto Lab
Phone:  416-448-3519, T/L 778-3519
E-mail:  neilg@ca.ibm.com



"asha" <le...@lecindia.com> on 12/12/1999 04:59:03 AM

Please respond to xerces-j-dev@xml.apache.org

To:   xerces-j-dev@xml.apache.org
cc:
Subject:  parser is not validating the xml document




I have an xml document as follows:

<?xml version="1.0" standalone="no"?>
<!DOCTYPE catalog SYSTEM "BookDTD.dtd" >
<catalog>
    <Book>
         <Author>asha</Author>
        <Publisher>Wrox</Publisher>
        <owner>asha</owner>
   </Book>
</catalog>

And the DTD (BookDTD.dtd) is as follows :

<!ELEMENT catalog (Book)>
<!ELEMENT Book (Author,Publisher)>
<!ELEMENT Author (#PCDATA)>
<!ELEMENT Publisher (#PCDATA)>

I have written a java program which will use Xerces parser to parse  the
document .Program as follows :

    DOMParser parser = new DOMParser();
    parser.setFeature("http://xml.org/sax/features/validation",true);
    parser.parse("file:///i:/akl/Security.xml");

 Since document is not written as per the DTD specification. It should give
me an error. But it parses the file without any error.
I have tried with Xerces2.0 version as well as Xerces1.2.3 version.
Can anybody tell me where is the problem.