commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jai PP <jpgulba...@yahoo.com>
Subject Re: Digester DTD validation
Date Sat, 19 Apr 2003 04:56:00 GMT
Ben,
Thanks a lot. I got it. 
- Jaiteerth

--- Ben Walding <default0001@walding.com> wrote:
> Yeah that's a nice little feature :)
> 
> You need to create an ErrorHandler for the digester
> 
> 
> eg
> 
> d.setErrorHandler(new ErrorHandler() {
>             public void warning(SAXParseException
> exception) throws 
> SAXException {
>                 //System.out.println("Warning: " +
> exception.toString());
>                 throw new
> RuntimeException(exception);
>             }
> 
>             public void error(SAXParseException
> exception) throws 
> SAXException {
>                 //System.out.println("Error: " +
> exception.toString());
>                 throw new
> RuntimeException(exception);
>             }
> 
>             public void fatalError(SAXParseException
> exception) throws 
> SAXException {
>                 throw new
> RuntimeException(exception);
>             }
>         });
> 
> 
> 
> Jai PP wrote:
> 
> >I am parsing the xml against the dtd using diegster
> >but the parse method does not throw any exception
> when
> >the xml does not match the dtd , it only displays
> the
> >error in the logfile. Do you know how to catch
> these
> >kind of dtd validation error. 
> >
> >Here is the sample code
> >          
> >try
> >{
> >	XMLReader parse =
>
>XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
> >         
>
>parse.setFeature("http://xml.org/sax/features/validation",
> >true);
> >          Digester digester = new Digester();
> >         
>
>digester.setFeature("http://xml.org/sax/features/validation",
> >true);
> >          digester.push(this);
> >          InputSource in = new InputSource(fin);
> >          en = new EntityResolverImpl();
> >          digester.setEntityResolver(en);
> >          digester.parse(in);
> >	System.out.println("continue");
> >}
> >catch(Exception e)
> >{
> >	System.out.println("Catch any exception");
> >}
> >181 [main] ERROR digester.Digester  - Parse Error
> at
> >line 42 column 12: The content of element type
> "ABC"
> >is incomplete, it must match "(T?,J?,CT)".
> >The content of element type "ADJUST" is incomplete,
> it
> >must match "(J?,J?,CT)".
> >continue
> >191 [main] E
> >
> >
> >thanks!
> >- Jai
> >
> >__________________________________________________
> >Do you Yahoo!?
> >The New Yahoo! Search - Faster. Easier. Bingo
> >http://search.yahoo.com
> >
>
>---------------------------------------------------------------------
> >To unsubscribe, e-mail:
> commons-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail:
> commons-user-help@jakarta.apache.org
> >
> >
> >  
> >
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> commons-user-help@jakarta.apache.org
> 


__________________________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo
http://search.yahoo.com

Mime
View raw message