You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "Jason E. Stewart" <ja...@openinformatics.com> on 2001/09/15 06:18:14 UTC
Reusing a {SAX,DOM,IDOM}Parser
Hey All,
I'd like to create a single parser instance, and then reuse it to
parse a few thousand small XML files over and over (the xmlconf test
suite).
The problem happens when I parse a file that causes an error. When I
try to parse the next file, it seems that the previous parse left the
parser in a bad state:
Received XMLException without handler
Exception thrown in file: 'SAXParser.cpp'
At line: '385'
Exception message is:
Parse may not be called while parsing
DOM seems to have a reset() method, but not SAX. When I try calling
DOM::reset(), or IDOM, I get an abort because it calls a pure virtual
method.
Any suggestions appreciated.
jas.
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: Reusing a {SAX,DOM,IDOM}Parser
Posted by "Jason E. Stewart" <ja...@openinformatics.com>.
"Jason E. Stewart" <ja...@openinformatics.com> writes:
> I'd like to create a single parser instance, and then reuse it to
> parse a few thousand small XML files over and over (the xmlconf test
> suite).
>
> The problem happens when I parse a file that causes an error. When I
> try to parse the next file, it seems that the previous parse left the
> parser in a bad state:
>
> Received XMLException without handler
> Exception thrown in file: 'SAXParser.cpp'
> At line: '385'
> Exception message is:
> Parse may not be called while parsing
>
> DOM seems to have a reset() method, but not SAX. When I try calling
> DOM::reset(), or IDOM, I get an abort because it calls a pure virtual
> method.
Hey,
I also tried using the SAXParser progressive parsing interface:
parseFirst(), parseNext(), and parseReset().
This works for a while, but eventually parseReset() throws an
undocumented XMLException from XMLScanner.cpp:818:
parseReset caused exception: XMLException:
FILE: XMLScanner.cpp
LINE: 818
CODE: _p_XMLExcepts__Codes=SCALAR(0x129590e0)
MESSAGE: The call to scanNext() is illegal at this time
Not exactly what I would call a useful error msg... What is
scanNext()? The exception is because of an invalid scan token, but I
don't know why a SAXParseException would cause the parse token to
become invalid.
I'm getting the sense that when Xerces' Parsers throw exceptions,
they are left in a fundamentally unstable state that cannot be
restored, and so one should *never* attempt to reuse a parser
instance.
I hope that I'm wrong, but I can't seem to get this working. Help is
appreciated.
jas.
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org