Thanks Simon!

> All the existing Digester object creation options
> (ObjectCreateRule, FactoryCreateRule) create the target object when the
> opening xml tag is found.

I see. In that case, I need to create the Text object when the <text>
tag is encountered. The question is, how do I save the information that
appears before the <text> tag?

<component>
<x>10</x> <y>20</y>
<text> Hello world </text>
</component>

I suppose that I could have some kind of dummy ComponentBuilder class
which would sit at the root of the stack and save the x/y value.
Something like this, maybe:

digester.addObjectCreate("component", ComponentBuilder.class);
digester.addSetNext("component/x", "addX"); // save x in ComponentBuilder
digester.addSetNext("component/y", "addY"); // save y in ComponentBuilder
digester.setTopRule("component/text", "setXY"); // initialialize Text.x
and Text.y
// from values saved in ComponentBuilder
digester.addSetNext("component/text", "setComponent"); // stores Text
obj in ComponentBuilder obj

ComponentBuilder foo = (ComponentBuilder) digester.parse();
Component realResult = foo.getComponent();

It's a bit ugly, but not so bad.

Bill



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to