Digester - DynamicDigester?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Digester - DynamicDigester?

timrobertson100
Hi,
I would like to configure some form of DynamicDigester to parse generic XML
that contains repeatable content into a List of Map.
Each repeating element means a new map, and the map is keyed on the pattern,
with the value being the digesting value.

So considering:

...
<record>
  <name>Tim</name>
  <age>21</age>
</record>
<record>
  <name>Tom</name>
  <age>22</age>
</record>
...

I would like to configure it with patterns "*/name" and "*/age" and also
with the pattern for the repeating element "*/record".

Then after digesting I would like a
List<Map<String, String>>

representing:
[name:Tim][age:21]
[name:Tom][age:22]

Can anyone help me with this?

Be aware that I want to digest different XML schemas with the same Digester,
but just register different patterns for the "items of interest" and the
marker for the repeating element.

So really, I am thinking a pattern to push onto the stack a new HashMap for
each repeat element, and then register patterns to put the Pattern as the
key and the result as the value.

Unfortunately I can't work out how to get the Pattern in a Rule firing...

Thanks for any help or advice!

Tim
Reply | Threaded
Open this post in threaded view
|

Re: Digester - DynamicDigester?

simon.kitching@chello.at
tim robertson schrieb:

> Hi,
> I would like to configure some form of DynamicDigester to parse generic XML
> that contains repeatable content into a List of Map.
> Each repeating element means a new map, and the map is keyed on the pattern,
> with the value being the digesting value.
>
> So considering:
>
> ...
> <record>
>   <name>Tim</name>
>   <age>21</age>
> </record>
> <record>
>   <name>Tom</name>
>   <age>22</age>
> </record>
> ...
>
> I would like to configure it with patterns "*/name" and "*/age" and also
> with the pattern for the repeating element "*/record".
>
> Then after digesting I would like a
> List<Map<String, String>>
>
> representing:
> [name:Tim][age:21]
> [name:Tom][age:22]
>
> Can anyone help me with this?
>
> Be aware that I want to digest different XML schemas with the same Digester,
> but just register different patterns for the "items of interest" and the
> marker for the repeating element.
>
> So really, I am thinking a pattern to push onto the stack a new HashMap for
> each repeat element, and then register patterns to put the Pattern as the
> key and the result as the value.
>
> Unfortunately I can't work out how to get the Pattern in a Rule firing...
>
> Thanks for any help or advice!
>  
Have you looked at the digester examples that are included in the source
download, or that can be accessed directly here?
 
http://svn.apache.org/repos/asf/commons/proper/digester/trunk/src/examples/

Regards,
Simon


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Digester - DynamicDigester?

timrobertson100
Sure, but I have not seen any examples that propogate the original pattern
(not the match as they are different) as the rule fires to the target of the
rule - I could implement Rule but that seems a bit overkill for something
that I expect can be done with the CallMethodRule.

Similarly I don't see any stack where I can get that pattern from.  I could
intercept the firing rule, but then I am modifying the core iterations of
the rule firing code.

Unless of course I am missing something very obvious!

Thanks
hmmm.. I might be able to use some kind of Dynabean and then conversion to
List<Map<String><String>>



On Mon, Mar 31, 2008 at 11:31 AM, [hidden email] <
[hidden email]> wrote:

> tim robertson schrieb:
> > Hi,
> > I would like to configure some form of DynamicDigester to parse generic
> XML
> > that contains repeatable content into a List of Map.
> > Each repeating element means a new map, and the map is keyed on the
> pattern,
> > with the value being the digesting value.
> >
> > So considering:
> >
> > ...
> > <record>
> >   <name>Tim</name>
> >   <age>21</age>
> > </record>
> > <record>
> >   <name>Tom</name>
> >   <age>22</age>
> > </record>
> > ...
> >
> > I would like to configure it with patterns "*/name" and "*/age" and also
> > with the pattern for the repeating element "*/record".
> >
> > Then after digesting I would like a
> > List<Map<String, String>>
> >
> > representing:
> > [name:Tim][age:21]
> > [name:Tom][age:22]
> >
> > Can anyone help me with this?
> >
> > Be aware that I want to digest different XML schemas with the same
> Digester,
> > but just register different patterns for the "items of interest" and the
> > marker for the repeating element.
> >
> > So really, I am thinking a pattern to push onto the stack a new HashMap
> for
> > each repeat element, and then register patterns to put the Pattern as
> the
> > key and the result as the value.
> >
> > Unfortunately I can't work out how to get the Pattern in a Rule
> firing...
> >
> > Thanks for any help or advice!
> >
> Have you looked at the digester examples that are included in the source
> download, or that can be accessed directly here?
>
>
> http://svn.apache.org/repos/asf/commons/proper/digester/trunk/src/examples/
>
> Regards,
> Simon
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Digester - DynamicDigester?

timrobertson100
Ok - I was overlooking something very simple

addObjectParam means I can propagate the pattern into the map key very
simply

Thanks

Tim


On Mon, Mar 31, 2008 at 11:37 AM, tim robertson <[hidden email]>
wrote:

> Sure, but I have not seen any examples that propogate the original pattern
> (not the match as they are different) as the rule fires to the target of the
> rule - I could implement Rule but that seems a bit overkill for something
> that I expect can be done with the CallMethodRule.
>
> Similarly I don't see any stack where I can get that pattern from.  I
> could intercept the firing rule, but then I am modifying the core iterations
> of the rule firing code.
>
> Unless of course I am missing something very obvious!
>
> Thanks
> hmmm.. I might be able to use some kind of Dynabean and then conversion to
> List<Map<String><String>>
>
>
>
>
> On Mon, Mar 31, 2008 at 11:31 AM, [hidden email] <
> [hidden email]> wrote:
>
> > tim robertson schrieb:
> > > Hi,
> > > I would like to configure some form of DynamicDigester to parse
> > generic XML
> > > that contains repeatable content into a List of Map.
> > > Each repeating element means a new map, and the map is keyed on the
> > pattern,
> > > with the value being the digesting value.
> > >
> > > So considering:
> > >
> > > ...
> > > <record>
> > >   <name>Tim</name>
> > >   <age>21</age>
> > > </record>
> > > <record>
> > >   <name>Tom</name>
> > >   <age>22</age>
> > > </record>
> > > ...
> > >
> > > I would like to configure it with patterns "*/name" and "*/age" and
> > also
> > > with the pattern for the repeating element "*/record".
> > >
> > > Then after digesting I would like a
> > > List<Map<String, String>>
> > >
> > > representing:
> > > [name:Tim][age:21]
> > > [name:Tom][age:22]
> > >
> > > Can anyone help me with this?
> > >
> > > Be aware that I want to digest different XML schemas with the same
> > Digester,
> > > but just register different patterns for the "items of interest" and
> > the
> > > marker for the repeating element.
> > >
> > > So really, I am thinking a pattern to push onto the stack a new
> > HashMap for
> > > each repeat element, and then register patterns to put the Pattern as
> > the
> > > key and the result as the value.
> > >
> > > Unfortunately I can't work out how to get the Pattern in a Rule
> > firing...
> > >
> > > Thanks for any help or advice!
> > >
> > Have you looked at the digester examples that are included in the source
> > download, or that can be accessed directly here?
> >
> >
> > http://svn.apache.org/repos/asf/commons/proper/digester/trunk/src/examples/
> >
> > Regards,
> > Simon
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
>