Hi list

I'd like to use Digester to parse an XML file. The root element ('definitions') should correspond to a HashMap. This HashMap should contain key/value pairs, whereas the value is a bean of type DefinitionBean and the key is stored within the DefinitionKey.

Here what I have so far:

Digester d = new Digester();
d.addObjectCreate("definitions", HashMap.class);
d.addObjectCreate("definitions/definition", DefinitionBean.class);
d.addBeanPropertySetter("definitions/definition/key", "key");
d.addObjectCreate("definitions/definition/properties/property", DefinitionProperty.class);


d.addBeanPropertySetter("definitions/definition/properties/property/xyz", "xyz");

d.addSetNext("definitions/definition/properties/property", "addProperty");
// And this stuff here isn't working of course,
// but shows maybe what I'd like to do.
DefinitionBean bean = (DefinitionBean) d.pop();
HashMap hashMap = (HashMap) d.pop();
hashMap.put(bean.getKey(), bean);
d.push(hashMap);
d.push(bean);


HashMap map = (HashMap) d.parse(getTestXmlReader());


When the definitions/definition tag ends I'd like to do something like
hashMap.put(bean.getKey(), bean)
whereas bean is of type DefinitionBean. The DefinitionBean is on top of the stack and below the HashMap. Then of course the DefinitionBean should be removed from stack for the next to come.


I don't see a way to do that and would be very happy for every hint on that.

Christian


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



Reply via email to