Re: [digester] delegate the parsing of some nodes to different parsers
On Wed, 2006-01-25 at 15:19 +0100, Valerio Schiavoni wrote:
> suppose you have something like:
> I already have the digester code to istantiate a Bar object, if given as
> parameter to BarParser.read(String s) i pass as
> actual parameter everything between <bar> and </bar>.
> Now i want to have a RootParser, so that if i pass it everything between
> root tags, whenever it encounter any bar tags,
> it delegates the parsing of that portion of the xml document to BarParser.
> Is it possible ?
I guess it's possible though I don't know of anyone that has tried this
You effectively need to get a reference to the xml parser that is
feeding events to the RootParser, and instead tell it to feed events to
the BarParser. In addition, I presume you'd need to grab the top object
off the RootParser's object stack and push it onto the BarParser's stack
so that the two "trees" of objects can be connected. At the end of the
bar element, you need to perform the reverse process. This sounds like
it is doable using a custom Rule class.