Lists Home |
Date Index |
- To: <email@example.com>
- Subject: Reusing a JAXP SAX parser
- From: "Bayly, Martin" <Martin.Bayly@webct.com>
- Date: Thu, 23 Oct 2003 13:18:13 -0700
- Thread-index: AcOZoslv1SRVKhghRLuiJxLl2bk9hQ==
- Thread-topic: Reusing a JAXP SAX parser
Title: Reusing a JAXP SAX parser
I have a situation where I'm parsing many instances of a document conforming to a given schema.
I was planning on reusing the same SAXParser instance to parse each document on the assumption that setting up the parser for each document might add overhead to the overall operation.
I'm able to reuse the same parser without any problems, but I'm concerned that I may be experiencing uncessary overhead in processing the schemas associated with the document I'm parsing.
I'm using the following to setup my parser i.e. using JAXP:
SAXParserFactory spf = SAXParserFactory.newInstance();
parser = spf.newSAXParser();
DefaultHandler handler = getHandler();
for each document input stream:
I find that my entity resolver gets called for each schema in the list of schemas for each document I process (which I guess isn't suprising given that the entity resolver is a feature of the handler which is passed into the parse call). However, this means that the parser is presumably parsing the same schema instance for every document. It would be nice if the parser could be setup with the schemas just once.
My underlying parser is xerces 2.2
Is this just something I shouldn't be worried about? Is is something that can be accomplished by using the parser's native interface?