cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Engelhart <>
Subject Re: XMLResourceBundle
Date Fri, 23 Jun 2000 14:29:07 GMT
on 6/23/00 3:24 AM, Niclas Hedhman at wrote:

> Thanks for a nice util.
> And I am 'stealing' it straight off, since I was half way with a similar
> thing.
> However,
> private static Document resource;
> ????
> That can't be right. You would want more than one resource document, right?
> Niclas
no problem.  I've done a lot to it since then.  For one (no private static
Document :-))..
Now it handles parent inheritance like java.util.ResourceBundle's allow and
also builds the whole parent chain at first access of the bundle.

For example if you have a parent hierachy of XML files such as:
*** words_en_us.xml ***
        <word key="THREE">

*** words_en.xml ***
        <word key="ONE">

*** words.xml ***
        <word key="ZERO">

You can call 
XMLResourceBundle bundle = XMLResourceBundle.getBundle("words", new
Locale("en", "us");
String word = 

The XMLResourceBundle's getString() will keep walking the parent chain until
it finds the correct match or else throw a MissingResourceException.

Still the issue remains that this class is much, much slower for accessing
items than ResourceBundle's are.   I think that ResourceBundle's load their
properties into a Hashtable so access is very fast - in some tests, randomly
accessing items from a 2000 item Properties file took on average - 0ms
whereas with that same file stored as an XML file, the fastest random access
time (even when done in a loop) was 489ms.  I've discussed this with the
Scott on the Xalan list and there are some possible workarounds that I'm
going to look at and also Xalan 2.0.0 should speed things up considerably as
well.   For smaller sets though it works nicely.

I'm not sure if this stuff has any value for Cocoon2 (1.x?) or not so I'm
not sure if I should post it to this list or just privately mail it.  I
don't want to load up this list with source code.


View raw message