Success! Thanks Wendy.
This is what worked, outside of a few small changes syntax changes, your
thinking is exactly correct.
public TreeMap digest() throws IOException, SAXException {
digester = new Digester();
digester.setValidating(false);
digester.addObjectCreate("DATA/VERSION", TreeMap.class);
digester.addCallMethod("DATA/VERSION/ITEM", "put", 2);
digester.addCallParam("DATA/VERSION/ITEM", 0, "NAME");
digester.addCallParam("DATA/VERSION/ITEM", 1);
return (TreeMap)digester.parse(parseMe);
}
Luke
----- Original Message -----
From: "Wendy Smoak" <[EMAIL PROTECTED]>
To: "Jakarta Commons Users List" <[email protected]>
Sent: Tuesday, February 01, 2005 3:19 PM
Subject: Re: Need a little help
> From: "Luke Shannon" <[EMAIL PROTECTED]>
>
> > public TreeMap digest() throws IOException, SAXException {
> > digester = new Digester();
> > digester.setValidating(false);
> > digester.addObjectCreate("DATA/VERSION", "createTreeMap");
>
> An ObjectCreateRule needs to know the type of object to create, not a
method
> to call. You need to let Digester create an object and push it on the
> stack, and calling createTreeMap won't do that.
>
> > digester.addSetProperties("DATA/VERSION/ITEM", "NAME", "name");
> > digester.addCallMethod("DATA/VERSION/ITEM", "addItem", 0);
> > return fieldsValues;
> > }
>
> I thought...
> digester = new Digester();
> digester.setValidating(false);
> digester.addObjectCreate("DATA/VERSION", "TreeMap.class");
> digester.addCallMethod("DATA/VERSION/ITEM", "put", 2);
> digester.addCallParam("DATA/VERSION/ITEM", 0, "NAME");
> digester.addCallParam("DATA/VERSION/ITEM", 1);
> return digester.parse(file);
>
> It should create a TreeMap and then call 'put' with the value of the NAME
> attribute and the body of the <ITEM> tag as the name/value pair. Some of
> the method params may be switched around, double check the signatures.
>
> HTH,
> --
> Wendy Smoak
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]