xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thomas.dewe...@kodak.com
Subject Re: XML Help
Date Fri, 09 Nov 2007 02:49:40 GMT
Hi Eric,

"Frederich, Eric P21322" <eric.frederich@siemens.com> wrote on 11/08/2007 
05:41:58 PM:

> Is there a light-weight way to create an xml document in Java?
> The following two lines take 2 full seconds.
> DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
> Document doc =
> impl.createDocument(SVGDOMImplementation.SVG_NAMESPACE_URI, "svg",
> null);
> The first one takes about 1.5 seconds and the second takes about 0.5
> seconds.

   This is all class loading time.  When a Batik SVGDocument is
created it registers factory classes for all of the element types in

> I'm not doing anything complicated like querying the document after it
> is created.

   Then you don't need to use Batik's implementation you can use any
DOM implementation.

> So is there a solution that is more light-weight even if it isn't SVG
> specific and just XML in general?

   You can use the JDK provided javax.xml.parsers.DocumentBuilder[Factory]
to create a generic Document.

> The problem is that this program will be run many times in batch mode
> and I can't afford the 2 seconds every iteration.

   You will only pay the 2sec penalty the first time you do this in
an invocation of a JVM.  Subsequent creations will be _much_ faster
(you should time how long it takes to create 100 Documents in a loop).

   This is why most "real" systems that use Java create one long
running JVM that hosts the various Java "services" (aka servlets).

View raw message