commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject Digester's pattern matching: bug or misunderstanding?
Date Mon, 19 Jan 2004 18:17:48 GMT
I'm currently writing an XML config file parser using the Digester framework. I've spent quite
a while debugging the digester code, since I really did not understand how digester was building
the object stack. I now understand it but am wondering if this is a bug ...

Here are the details. My XML document roughly has the following structure (strongly simplified
for demonstration purposes):



I now have added the following rules:

	digester.addObjectCreate("*/my-sender", Sender.Class);
	digester.addObjectCreate("*/managed-object", ManagedObject.Class);
	digester.addObjectCreate("*/multi-dimension", MultiDimensionObject.Class);
	digester.addObjectCreate("*/descriptor", Descriptor.Class);

	digester.setNextRule("*/managed-object/descriptor", "setDescriptor");
	digester.setNextRule("*/other-dimension/descriptor", "doSomethingElse");

With this setup the "Descriptor" object is *NOT* created, since the rules associated with
the longer
"*/managed-object/descriptor" or "*/other-dimension/descriptor" matches are executed before
the ObjectCreateRule which is matched by "*/descriptor".

Digester now calls the "setDescriptor" method on a Sender instance instead of on a ManagedObject

I would expect Digester to create the "Descriptor" object before doing anything else with
the object. It seems that digester does not handle rules in the proper order. Some rules are
clearly associated with the creation (invoked in start() function) of an element (e.g. ObjectCreateRule).
Other rules (e.g. SetNextRule)  should be invoked after object creation (invoked in end()
function). However digester does not seem to take this into account.

Is this a bug, or do I need more clarification on how the matching patterns really influence
digester's behavior? Comments are welcome.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message