[jdom-interest] JDOM taking too much time to convert xml string to Document object

Chabbewal, Navjeet navjeet.chabbewal at us.didata.com
Tue May 7 13:04:20 PDT 2002


I have been using JDON ony my project for a while but recently we had a
modification in a dtd which seens to cause an substantial increase in
the time taken to convert an xml string into Document object. The change
was that one of the elements which had 22 sub-elements now has 39
sub-elements. Now this is the weird behaviour I am seeing. When the xml
string does not have one particular xml element ( one of the 39
sub-elements) it takes 4-5 times more time to process the xml. All these
sub-elements are optional. I have been using JDOM-B7 but I downloaded
JDOM-B8 with the same results. Here is the code to convert the xml to
Document object:
 
 public Document buildDocument(String xml) throws XMLConversionException
{
        Timer methodTimer = new Timer("buildDocument(xml)");
        methodTimer.start();
        Document   document   = null;
        SAXBuilder saxBuilder = new SAXBuilder(true);
        try {
            document =
                saxBuilder.build(new InputSource(new
StringReader(xml)));
        } catch (JDOMException e) {
            log.error("build document failed", e);
            throw new XMLConversionException(e.toString());
        }
        methodTimer.stop();
        log.info( methodTimer.toString() );
        return document;
    }
 
I have xerces and xalan jar files which come with JDOM in my classpath
before jdom jar file.
 
Any ideas what could be happening !!!!
 
 
--Navjeet
 



More information about the jdom-interest mailing list