commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jaap van Hengstum" <>
Subject [Digester] NodeCreateRule
Date Mon, 28 Jul 2003 16:21:22 GMT
I'm at a loss using NodeCreateRule. I have the following xml structure:

	<item class="nl.indicia.quokka.init.TestContextItem">

I want to parse it with a digester. I also have the following class (TestContextItem inherits
this class):

public abstract class ContextItem
	protected String configurationFile;
	protected Node propertiesRoot;
	// -------------------------------------------------------------------------
	public String getConfigurationFile()
		return this.configurationFile;
	public void setConfigurationFile(String configurationFile)
		this.configurationFile = configurationFile;
	public Node getNode()
		return this.propertiesRoot;
	public void setNode(Node node)
	    this.propertiesRoot = node;

	// -------------------------------------------------------------------------
	public abstract void initialize() throws FrameworkException;
	public abstract void reinitialize() throws FrameworkException;

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. 

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)??? 

(and if this is not possible using the standard digester rules, what new rule should I create?)

If someone could answer this, he or she would make me very happy :-)


View raw message