Return-Path: Mailing-List: contact cocoon-dev-help@xml.apache.org; run by ezmlm Delivered-To: mailing list cocoon-dev@xml.apache.org Received: (qmail 82030 invoked from network); 23 Jun 2000 14:39:51 -0000 Received: from mta4.rcsntx.swbell.net (151.164.30.28) by locus.apache.org with SMTP; 23 Jun 2000 14:39:51 -0000 Received: from [209.184.0.98] by mta4.rcsntx.swbell.net (Sun Internet Mail Server sims.3.5.2000.01.05.12.18.p9) with ESMTP id <0FWM00C1S2WP5T@mta4.rcsntx.swbell.net> for cocoon-dev@xml.apache.org; Fri, 23 Jun 2000 09:29:14 -0500 (CDT) Date: Fri, 23 Jun 2000 09:29:07 -0500 From: Mike Engelhart Subject: Re: XMLResourceBundle In-reply-to: <39531EB5.BA6B0152@localbar.com> To: cocoon-dev@xml.apache.org Message-id: MIME-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit User-Agent: Microsoft-Outlook-Express-Macintosh-Edition/5.02.2022 X-Spam-Rating: locus.apache.org 1.6.2 0/1000/N on 6/23/00 3:24 AM, Niclas Hedhman at niclas@localbar.com 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 *** Three *** words_en.xml *** Two *** words.xml *** Zero You can call XMLResourceBundle bundle = XMLResourceBundle.getBundle("words", new Locale("en", "us"); String word = bundle.getString("/resources/words/word[@key=\"ZERO\"]/value"); 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. Mike