commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Bourg <ebo...@micropole-univers.com>
Subject Re: [digester] CallMethodRule order [bug12997] attn: Emmanuel, Craig
Date Fri, 27 Feb 2004 11:32:55 GMT
Simon Kitching wrote:

> The question in my mind is still: what use cases require the
> CallMethodRule to fire when the params are available?

Ok I remember why I needed this feature. I wanted to parse a file of 
i18n labels and insert them in a database. The file looked like this :

<messages>
   <message key="global.cancel">
     <label lang="en">Cancel</label>
     <label lang="fr">Annuler</label>
   </message>
   <message key="global.apply">
     <label lang="en">Apply</label>
     <label lang="fr">Appliquer</label>
   </message>
</messages>

I first pushed a "MessageFactory" on the stack with the following 
interface :

interface MessageFactory {
     void setKey(String key);
     void addLabel(String lang, String label);
}

and the parsing rules were :
- call setKey() on messages/message using the key attribute
- call addLabel() on messages/message/lang. This method issued the 
INSERT in the database, using the key previously specified.


I was then surprised to find in my database :

global.cancel=Apply

That's how I discovered that the call to setKey() was issued after the 
call to addLabel().

I admit I could have done it differently, but that illustrates the case 
of a rule fired on a child element depending on a context parameter set 
by a rule fired at the beginning of the parent element.

Emmanuel Bourg


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message