[jdom-interest] [Fwd: Re: SAX/SAX2 parser reusability]

Jason Hunter jhunter at acm.org
Fri Mar 15 17:44:11 PST 2002


I'm fine with having SAXBuilder reuse the parser instance, at least
until we get too many complaints of non-compliant parsers making this a
bad idea.  If someone wants to send a patch, I'll check it in.

-jh-

Dennis Sosnoski wrote:
> 
> Here's the official word on SAX/SAX2 parser reusability, confirming my
> earlier email. If a parser's not reusable it's not compliant with the
> specification. I'd suggest it's better to base JDOM's behavior on the
> specification and reuse the parser.
> 
>   - Dennis
> 
>   ------------------------------------------------------------------------
> 
> Subject: Re: SAX/SAX2 parser reusability
> Date: Fri, 15 Mar 2002 12:03:31 -0800
> From: David Brownell <david-b at pacbell.net>
> To: Dennis Sosnoski <dms at sosnoski.com>
> CC: David Megginson <david at megginson.com>
> References: <E16lorW-0004pT-00 at usw-sf-web1.sourceforge.net>
>      <15505.59043.661672.183245 at megginson.com> <3C924B61.1060803 at sosnoski.com>
> 
> Dennis --
> 
> SAX parsers that can't be re-used after they (or some
> handler they call) throw an exception are nonconformant.
> Throwing an exception should only abort the current parse.
> As it says in the javadoc for XMLReader.parse():
> 
>     Once a parse is complete, an application may reuse
>     the same XMLReader object, possibly with a different
>     input source. ... If a client application wants to terminate
>     parsing early, it should throw an exception.
> 
> Throwing an exception just causes "early" completion.
> 
> I'm not sure what javadoc seems to suggest otherwise;
> could you point it out to me?
> 
> FWIW, that's the policy I'd expect from instances of any
> class whatsoever, unless its interface spec said quite
> explicitly that it self-corrupted when throwing exceptions.
> 
> - Dave
> 
> ----- Original Message -----
> From: "Dennis Sosnoski" <dms at sosnoski.com>
> To: "David Brownell" <dbrownell at users.sourceforge.net>
> Cc: "David Megginson" <david at megginson.com>
> Sent: Friday, March 15, 2002 11:28 AM
> Subject: Re: SAX/SAX2 parser reusability
> 
> > Hi DavidB,
> >
> > This is in regard to a current discussion on the JDOM email list, so I'd
> > like permission to forward your response there. The issue is whether
> > parser reusability is something that can be depended on.
> >
> > Thanks,
> >
> >   - Dennis
> >
> > David Megginson wrote:
> >
> > >Dennis Sosnoski writes:
> > >
> > > > I can see where the documentation might be subject to
> > > > different interpretations - the error handling code says the
> > > > parser can basically die after throwing a fatal exception.
> > > > My own interpretation is that the parser can die *for that
> > > > document only*, and must still be usable with other
> > > > documents on later calls to parse.
> > >
> > >That was my intention as well -- that the parser should be reusable
> > >for a new parse.  I've copied the current SAX maintainer, David
> > >Brownell, so that he can decide whether any documentation
> > >clarifications are in order.
> > >
> > >
> > >All the best,
> > >
> > >
> > >David
> > >
> >
> >



More information about the jdom-interest mailing list