Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] XOM 1.1d1: setInternalDTDSubset

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Wolfgang Hoschek <whoschek AT lbl.gov>
  • To: Elliotte Harold <elharo AT metalab.unc.edu>
  • Cc: xom-interest <xom-interest AT lists.ibiblio.org>
  • Subject: Re: [XOM-interest] XOM 1.1d1: setInternalDTDSubset
  • Date: Sun, 16 Jan 2005 21:20:02 -0800

I can't imagine that there'll be that many or frequent calls to setInternalDTDSubset, but if this actually proves to be a performance hit, then maybe I can explore using ThreadLocals instead.

It doesn't occur in my use cases, but if one had an app that exchanges many identically formed small XML protocol messages and that app happened to use internal DTD subsets it would take a large hit. So more immediately useful than a ThreadLocal is a small string cache similar in spirit to Verifier.URICache. I think that should eliminate problems for all but bizarre use cases. Checking for a cache hit with == doesn't make much sense here; one needs to check with equals(). I think keeping the same cache size (6) is just fine.

I just hacked this together by adding a containsEqual(String) method to Verifier.URICache. Like this:

boolean containsEqual(String s) {
for (int i = 0; i < LOAD; i++) {
if (s.equals(cache[i])) return true;
}
return false;
}

[With that URICache might perhaps better be called "StringCache".]
And checkInternalDTDSubset(String subset) now reads:

// For use in checking internal DTD subsets
private static XMLReader parser;
private static URICache internalDTDSubsetCache = new URICache();

static synchronized void checkInternalDTDSubset(String subset) {
if (internalDTDSubsetCache.containsEqual(subset)) return;

... checking goes here same as before

internalDTDSubsetCache.put(subset);
}

Thoughts?
Wolfgang.





Archive powered by MHonArc 2.6.24.

Top of Page