[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Reusing a JAXP SAX parser

  • To: <xml-dev@l...>
  • Subject: Reusing a JAXP SAX parser
  • From: "Bayly, Martin" <Martin.Bayly@w...>
  • Date: Thu, 23 Oct 2003 13:18:13 -0700
  • Thread-index: AcOZoslv1SRVKhghRLuiJxLl2bk9hQ==
  • Thread-topic: Reusing a JAXP SAX parser

jaxp sax
Title: Reusing a JAXP SAX parser

hi

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();
            spf.setValidating(true);
            spf.setNamespaceAware(true);
            parser = spf.newSAXParser();
            parser.setProperty(XMLSchema.JAXP_SCHEMA_LANGUAGE, XMLSchema.W3C_XML_SCHEMA);
            parser.setProperty(XMLSchema.JAXP_SCHEMA_SOURCE, schemas.toArray());
        DefaultHandler handler = getHandler();

        for each document input stream:

            parser.parse(inputStream, handler);

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?

Thanks
Martin




PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.