How do you cache the parser?
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]] On Behalf Of James
Strachan
Sent: Wednesday, August 28, 2002 7:50 AM
To: Bram Huenaerts; DOM4J-user (E-mail)
Subject: Re: [dom4j-user] DOMReader related problem (Performace)
Creating a W3C DOM tree just to create a dom4j tree seems a bit
excessive.
Why not just use the SAXReader?
Also, if ever you have an XML parsing performance problem, try caching
the
parser. Often parsers take quite a while to 'warm up' particularly
things
like Xerces.
e.g. if using the dom4j SAXReader, it can often be useful to use
ThreadLocal
to pool them by thread. e.g.
ThreadLocal pool= new ThreadLocal() {
protected Object initialValue() {
return new SAXReader();
}
};
...
SAXReader reader = (SAXReader) pool.get();
reader.parse( "foo.xml" );
James
-------
http://radio.weblogs.com/0112098/
----- Original Message -----
From: "Bram Huenaerts" <[EMAIL PROTECTED]>
To: "DOM4J-user (E-mail)" <[EMAIL PROTECTED]>
Sent: Tuesday, August 27, 2002 8:46 AM
Subject: [dom4j-user] DOMReader related problem (Performace)
> Hi,
>
> I wonder what i can do about the following problem.
> I want to create a dom4j document from a org.w3c document.
> The code below works fine for xml-files under the +-100k.
>
> <CODE>
> // Parse the file to an org.w3c.dom.Document
> DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
> DocumentBuilder builder = factory.newDocumentBuilder();
> domDocument = builder.parse(new java.io.File(pathName));
>
> // Create an org.dom4j.Document
> DOMReader domReader = new DOMReader();
> document = domReader.read(domDocument);
> </CODE>
>
> Is this a performance problem or am I using the API not correctly?
> Can i go around this somehow?
> Any help is appreciated.
>
> regards
>
> Bram
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by: OSDN - Tired of that same old
> cell phone? Get a new here for FREE!
> https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
> _______________________________________________
> dom4j-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/dom4j-user
>
__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
-------------------------------------------------------
This sf.net email is sponsored by: Jabber - The world's fastest growing
real-time communications platform! Don't just IM. Build it in!
http://www.jabber.com/osdn/xim
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user
-------------------------------------------------------
This sf.net email is sponsored by: Jabber - The world's fastest growing
real-time communications platform! Don't just IM. Build it in!
http://www.jabber.com/osdn/xim
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user