commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <>
Subject Re: [Digester] element names
Date Tue, 08 Jul 2003 23:25:01 GMT
On Wed, 2003-07-09 at 04:54, Lister, Tom (ANTS) wrote:
> Hi
> I'm need to parse an XML document and cross reference selected elements with
> a mapping database to resolve different naming conventions between systems.
> We are using XML via MQ for real time integration.
> My problem is that when I get the content of an element to call a mapping
> method call, I also want to pass the name of the element as a second
> parameter to the method. I can't see a way to get this information.
> Alternatively a way to pass in a hard coded parameter would also work as I
> know which elements I am defining rules for.
> I can't see any way to pass parameters to a method call other than element
> contents - or have I missed something basic.
> Do I need to build a custom rule for this?

I don't think what you want to do can be accomplished without extending
Digester in one way or another.

Digester class has a getCurrentElementName() method.
The Rule class (which is extended by every type of Rule) has a
getDigester() method. So yes I think you could write a custom rule which
passes the element name.

Your suggestion about passing a constant string as a parameter also
sounds reasonable but as far as I am aware, CallMethodRule/CallParamRule
do not currently support passing constants as parameters. I think that
this feature would be a nice addition to Digester; eg adding a new
  public CallParamRule(int paramIndex, Object paramObj)

If you did implement constant parameters, I think it would be a good
candidate for inclusion in Digester (not that my opinion counts for
anything :-). 



View raw message