Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] baseURI / systemID question

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Harold <elharo AT metalab.unc.edu>
  • To: Wolfgang Hoschek <whoschek AT lbl.gov>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] baseURI / systemID question
  • Date: Mon, 13 Sep 2004 16:33:49 -0400

Wolfgang Hoschek wrote:

The reason I'm asking requires some background:
I worked on XOM extensions for a high-performance messaging environment using small XML messages. I started with dozens of messages/sec throughput, and after a lot of sweat have now reached thousands of messages/sec (even when turning on W3C XML Schema validation).

Doing some profiling it turns out that the baseUri calculation in Builder.build(File) takes much more time than all of file I/O, parsing and validation combined. The reason is that Builder.build(File) use URLEncoder.encode(String.valueOf(char)) in a loop to compute the baseURI. To confirm that, try replacing the calculation with File.toURI().toString() or a combination of the code found in FileSource.setSystemID(File file) with URIUtil.toURI(...).

That's strange. I guess it's just one of the unoptimized parts of the core API. If you know the URL you're starting with, you should probably just pass it in along with the FileInputStream, rather than letting Java calculate it for you. However, there is one advantage to letting Java do the calculation. The format of file URLs varies a bit from platform to platform. Letting the File class figure it out gives correct results on Windows, Unix, and other platforms.

I'd be tempted to file a bug report with Sun on this one. There's no reason URL encoding should take longer than XML parsing. It's a very straightforward operation. I could write my own code to create file URLs from a File object. However, I'd be very nervous about getting it wrong on some platforms, and also causing problems if Sun ever updates their VM so this operation works reasonably.

--
Elliotte Rusty Harold
elharo AT metalab.unc.edu





Archive powered by MHonArc 2.6.24.

Top of Page