commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <si...@ecnetwork.co.nz>
Subject Re: [Digester] NodeCreateRule
Date Mon, 28 Jul 2003 23:13:57 GMT
On Tue, 2003-07-29 at 04:21, Jaap van Hengstum wrote:
> I'm at a loss using NodeCreateRule. I have the following xml structure:
> What I understand of the NodeCreateRule, it should allow me to consider everything between
the <properties> tags as a xml node and pass this node to the instantiated ContextItem
class using the setNode method on that class. But I can't figure out how to do that. 
[snip]
> 
> I have the following digester configuration:
> 
> 	...
> (1)	this.addObjectCreate("init/item", "class", ContextItem.class);
> (2)	this.addSetNext("init/item", "addItem");
> (3)	this.addCallMethod("init/item/configuration-file", "setConfigurationFile", 0);
> (4)	this.addRule("init/item/properties", new NodeCreateRule());
> 	...
> 
> How do I continue after the NodeCreateRule? That is, how do I pass the contents of the
node on the object stack I  create in line (4) to the SetNode method on the TestContextItem
instance created in line (1)??? 

I haven't used NodeCreateRule myself, but I'm willing to have a stab at
an answer...

According to the Digester docs:
  The created Node will be pushed on Digester's object stack when done.

So I would guess that you just follow (4) above with
  this.addSetNext("init/item/properties", "setNode");

This will grab the second-to-last object on the stack (which is your
ContextItem object), and call its setNode method passing the last object
on the stack (which is the Node object just created & pushed there by
the NodeCreateRule).

If you find you get an exception indicating "no such method", then try
using CallMethodRule in place of SetNextRule, which allows you to
specify the parameter types for the target method.

If this doesn't work, then I suggest turning up digester logging to
maximum, which will provide you with *all* the debug info you will ever
need :-). Digester uses commons-logging, so see that module for how to
adjust logging levels.

Regards,

Simon


Mime
View raw message