cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Boag/CAM/Lotus" <>
Subject Re: XMLResourceBundle
Date Sat, 24 Jun 2000 15:38:51 GMT

BTW, Joe's idea of using IDs was a good one, and simpler than the key()
idea I was suggesting.


                    Mike Engelhart                                                       
                    <mengelhart@eart        To:         
          >              cc:     (bcc: Scott Boag/CAM/Lotus)       
                                            Subject:     Re: XMLResourceBundle           
                    06/23/2000 10:29                                                     
                    Please respond                                                       
                    to cocoon-dev                                                        

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,
> 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
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,
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
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
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