OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Reusing a JAXP SAX parser

[ Lists Home | Date Index | Thread Index ]
  • To: <xml-dev@lists.xml.org>
  • 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

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







 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS