Add these system properties to your code and you may see a DRAMATIC increase
in performance in DOM creation as well as Xpath and Transformer creation.
Using this technique bypasses a lot of very expensive factory overhead which
involves searching in the JAR file and the classpath for configuration
information.
// Xalan
System.setProperty("javax.xml.transform.TransformerFactory",
"org.apache.xalan.processor.TransformerFactoryImpl");
System.setProperty("org.apache.xml.dtm.DTMManager",
"org.apache.xml.dtm.ref.DTMManagerDefault");
// Xerces
System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
"org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
System.setProperty("javax.xml.parsers.SAXParserFactory",
"org.apache.xerces.jaxp.SAXParserFactoryImpl");
System.setProperty("org.apache.xerces.xni.parser.XMLParserConfiguration",
"org.apache.xerces.parsers.XML11Configuration");
Rick Bullotta
CTO
Lighthammer Software (http://www.lighthammer.com)
-----Original Message-----
From: Jos van den Oever [mailto:jvdoever@xxxxxxxxx]
Sent: Monday, February 14, 2005 6:56 AM
To: xerces-j-user@xxxxxxxxxxxxxx
Subject: Re: dom build speed
> I've run up against this problem as well. If I'm not mistaken, the
> problem is the way Xerces handles setting properties on a DOM parser
> via the JAXP interfaces. Xerces will create a new instance (!) of the
> DOMParser class for every single property you set (i.e., via
> setValidating(), setNamespaceAware(), etc.). This wouldn't be so bad
> if it wasn't so expensive to create a DOMParser instance, but it is.
> You should really be timing the parse and not the setup and parse.
>
> I was sort of shocked when I first discovered how poorly Xerces
> handles setting JAXP DocumentBuilder properties, but from
> conversations on this mailing list it's obviously a known problem and
> there doesn't seem to be much that can be done about it. Shrug.
Hello Curtis,
What I didn't mention: I'm reusing the DocumentBuilder and this gives me
only
a small speedup. What I'm timing is the parsing itself, not the creation of
the DocumentBuilder. Even if creating the DocumentBuilder was really slow,
it
wouldn't really be a problem because I'm using it in a Bean and it's only
created once per Bean.
Cheers, Jos
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xxxxxxxxxxxxxx
For additional commands, e-mail: xerces-j-user-help@xxxxxxxxxxxxxx
|
Try Searching:
servers, voip, java, networking, microsoft ...
|
|
|
|