Milind:

If I understand what the ErrorHandler is supposed to
do, it's going to have its warning, error, and fatal
error methods called when there's a problem.  (The
argument to each one is SAXParseException.)  I thought
that passing a document that was invalid against the
schema would trigger one of those three events.

I can certainly try your suggestion and have each of
these methods rethrow a SAXException.

But if you're asking why I need an ErrorHandler at
all, why I don't just have the parser signal the
failure by throwing an exception, I agree with you -
that's what I thought would happen.  But it didn't, so
I was following a suggestion from this mailing list to
write an ErrorHandler.

You might be right.  What else could I be doing to
obviate the need for an ErrorHandler?  I've set the
features on the parser, as well as I understand them. 
Perhaps I'm missing something else. - MOD


--- Milind Gadre <[EMAIL PROTECTED]> wrote:
> Michael, why don't you throw the exception from the
> error and warning
> methods??? Just printing the error is essentially
> not doing anything.
> 
> Regards...
> 
> Milind Gadre
> ecPlatforms, Inc
> 901 Mariner's Island Blvd, Suite 565
> San Mateo, CA 94404
> C: 510-919-0596
> F: 815-352-0779
> [EMAIL PROTECTED]
> 
> >
> > I wrote a class that implements ErrorHandler. 
> Each
> > method just writes out details for warning, error,
> and
> > fatal error cases as the interface demands.  I
> > instantiated an instance and passed it to my
> parser's
> > setErrorHandler() method.
> >
> > Still the bad document that I gave it parsed and
> > validated.
> >
> > I'm using the personal-schema.xml and personal.xsd
> > files that come in xerces data directory.  I've
> > downloaded Xerces 1.3, so I'm up-to-date.
> >
> > The bad document has the first <person> tag
> commented
> > out, like this:
> >
> > <!--  <person id="Big.Boss" > -->
> >   <person>
> >
> > The schema says the id attribute is required, so
> I'd
> > figure that Xerces would complain.
> >
> > I've got a few features turned on:
> >
> >
>
parser.setFeature("http://xml.org/sax/features/validation";,
> > true);
> >
> >
>
parser.setFeature("http://apache.org/xml/features/validation/dynamic";,
> > true);
> >
> >
>
parser.setFeature("http://apache.org/xml/features/validation/schema";,
> > true);
> >
> > parser.setErrorHandler(new SchemaErrorHandler());
> >
> > Any other thoughts would be appreciated.  Thanks
> for
> > your help. - MOD
> >
> >
> >
> > --- Sam Pullara <[EMAIL PROTECTED]> wrote:
> > > Are you listening for the error events that are
> > > coming off the ErrorHandler?
> > > Validation errors are not fatal errors and will
> not
> > > automatically generate
> > > exceptions.  You need to listen for the "error"
> > > event from the handler.
> > >
> > > Sam
> > >
> > > -----Original Message-----
> > > From: Michael Duffy [mailto:[EMAIL PROTECTED]
> > > Sent: Thursday, February 22, 2001 10:53 AM
> > > To: [EMAIL PROTECTED]
> > > Subject: Re: AW: Validation ?
> > >
> > >
> > >
> > > This example is lovely, but it doesn't use
> schemas.
> > > Have you got a successful example of that?  By
> > > "successful", I mean an example that will
> succeed
> > > AND
> > > fail to validate.
> > >
> > > Every document I feed to Xerces with a schema is
> > > parsed and "validated" successfully, even those
> that
> > > I
> > > believe should fail.  It tells me that I
> probably
> > > don't tell Xerces where the .xsd file is
> correctly.
> > >
> > > --- "Werner, Sven" <[EMAIL PROTECTED]> wrote:
> > > > Hi!
> > > > Look At: http://ecerami.com/xerces/
> > > > <http://ecerami.com/xerces/>  Theres an
> > > > Example of an validating parser written with
> > > xerces!
> > > >
> > > >
> > > > -----Urspr|ngliche Nachricht-----
> > > > Von: Matt Minyard
> > > [mailto:[EMAIL PROTECTED]
> > > > Gesendet am: Donnerstag, 22. Februar 2001
> 17:29
> > > > An: [EMAIL PROTECTED]
> > > > Betreff: Validation ?
> > > >
> > > > Hi,
> > > >
> > > >     I'm having a problem using the validating
> > > > feature.  I'm using the
> > > > following code to create the parser and set
> > > > validiation to true (I thought),
> > > > but documents with invalid tags are not
> generating
> > > > exceptoins.  Any ideas?
> > > >
> > > > dom = new DOMParser();
> > > > dom.setFeature("
> > > > http://xml.org/sax/features/validation
> > > > <http://xml.org/sax/features/validation> ",
> true);
> > > >
> > > > Thanks,
> > > >
> > > > Matt
> > > >
> > > >
> > > >
> > >
> >
>
---------------------------------------------------------------------
> > > > To unsubscribe, e-mail:
> > > > [EMAIL PROTECTED]
> > > > For additional commands, e-mail:
> > > > [EMAIL PROTECTED]
> > > >
> > >
> > >
> > >
> __________________________________________________
> > > Do You Yahoo!?
> > > Yahoo! Auctions - Buy the things you want at
> great
> > > prices!
> > > http://auctions.yahoo.com/
> > >
> > >
> >
>
---------------------------------------------------------------------
> > > 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]
> > >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Yahoo! Auctions - Buy the things you want at great
> prices!
> http://auctions.yahoo.com/
> >
> >
>
---------------------------------------------------------------------
> > 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]
> 


__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices! 
http://auctions.yahoo.com/

Reply via email to