You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Craig Tataryn <cr...@hotmail.com> on 2002/03/04 21:19:07 UTC

Digester Question

I realize that the digester is now part of commons, but I figure there is 
probably a lot of expertise here since it grew up in Struts.  I was 
wondering if someone could help me figure out the easiest way to do this:

I have an xml document, that holds form data, I would like to use the 
digester to populate my objects automatically.  A form file might look like 
this:

<forms>
  <form type="shopping-cart">
     ....
  </form>
  <form type="calculator">
  ...
  </form>
...
</forms>

Let's assume there are many forms...  I was wondering, without having to 
load all forms into objects and then picking the one I want to use, I would 
rather the digester only instantiate and populate an object for lets say, 
the form node who's type attribute is "calculator".

What's the easiest way to do this?  I don't think the digester can pattern 
match on attribute values the way XPath does, so is there a programming 
technique I can use to filter further?

Thanks,

Craig.

Craig W. Tataryn
Programmer/Analyst
Compuware

_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Digester Question

Posted by Steve A Drake <sa...@comet.ucar.edu>.
On Mon, 4 Mar 2002, Craig Tataryn wrote:

> I realize that the digester is now part of commons, but I figure there is
> probably a lot of expertise here since it grew up in Struts.  I was
> wondering if someone could help me figure out the easiest way to do this:
>
> I have an xml document, that holds form data, I would like to use the
> digester to populate my objects automatically.  A form file might look like
> this:
>
> <forms>
>   <form type="shopping-cart">
>      ....
>   </form>
>   <form type="calculator">
>   ...
>   </form>
> ...
> </forms>
>
> Let's assume there are many forms...  I was wondering, without having to
> load all forms into objects and then picking the one I want to use, I would
> rather the digester only instantiate and populate an object for lets say,
> the form node who's type attribute is "calculator".
>
> What's the easiest way to do this?  I don't think the digester can pattern
> match on attribute values the way XPath does, so is there a programming
> technique I can use to filter further?

 Hi Craig. Since, AFAIK, the digester blindly instantiates all of the
implied objects in your database file, I think that you'll need to parse the
database file independently. You might try parsing the database file
using JDOM, extracting the elements that you want and passing that
snippet to the digester. I think that utilizing JDOM, you'll get working
code much faster than you would with raw SAX parsing. I have used
JDOM but I haven't tried utilizing it with the digester - just an idea.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>