commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject [digester] Grabbing data from sub-element attributes
Date Fri, 13 May 2011 21:33:22 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

All,

I'm trying to process a document that has some data as PCDATA in
sub-elements, but some data in attributes of those sub-elements. I have
a simple POJO to store the data, but I'm having difficulty gathering
both pieces of information.

Here's an example POJO and XML document.

public class Entity
{
   public void setFoo(String foo);
   public void setBar(String bar);
   public void setBaz(Integer baz);
}

<entities>
  <entity>
    <foo>some value</foo>
    <bar>some other value</bar>
    <baz id="123" />
  </entity>
</entities>

What I'd like to do is have "setBaz" called with the value from the
<baz> element's "id" element. Is that possible with the existing set of
Rule classes?

If not, what's the best way to implement it?

I know I could always write another simple POJO called "Baz" (or
whatever), give it a "setId" method, add setBaz(Baz) to the Entity class
and then use a more complicated set of rules, but that really seems like
overkill.

Any suggestions?

Thanks,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk3No6IACgkQ9CaO5/Lv0PCT1gCgjv31KUf+K/wbwuClNBR5dkDJ
HDUAn34F4W+MiwYmlOgRykfYbhwKVsE+
=NZ/g
-----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