commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rahul Akolkar <rahul.akol...@gmail.com>
Subject Re: [digester] Grabbing data from sub-element attributes
Date Fri, 13 May 2011 21:53:22 GMT
On Fri, May 13, 2011 at 5:45 PM, Christopher Schultz
<chris@christopherschultz.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> All,
>
> Wouldn't you know it, just after I posted, I had an epiphany:
>
> On 5/13/2011 5:33 PM, Christopher Schultz wrote:
>> <entities>
>>   <entity>
>>     <foo>some value</foo>
>>     <bar>some other value</bar>
>>     <baz id="123" />
>>   </entity>
>> </entities>
>
> The solution is:
>
> digester.addObjectCreate("entities/entity", Entity.class);
>
> digester.addSetNestedProperties("entities/entity",
>                                { "foo", "bar", "baz" },
>                                { "foo", "bar", null }); // ignore baz
>
> // go back and get "baz"
> digester.addSetProperties("entities/entity/baz", "id", "baz");
>
<snip/>

Yeah, and probably more than one way even with out of the box rules:

  d.addObjectCreate("entities/entity", Entity.class);
  d.addCallMethod("entities/entity/foo", "setFoo", 0);
  d.addCallMethod("entities/entity/bar", "setBar", 0);
  d.addCallMethod("entities/entity/baz", "setBaz", 1);
  d.addCallParam("entities/entity/baz", 0, "id");

-Rahul


> Sorry for the noise.
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk3Npo0ACgkQ9CaO5/Lv0PDG0ACgpYqGZOM054nO/bLNypyfrKPx
> iysAnjqdjkrsQT4l3qlj1OLJp4vG4sbT
> =n7/z
> -----END PGP SIGNATURE-----
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message