Thanks, it given me some new leads.
-----Original Message-----
From: Simon Kitching [mailto:[EMAIL PROTECTED]
Sent: Sunday, 21 December 2003 7:27 PM
To: Jakarta Commons Users List
Subject: Re: Parsing unlimited xml element nesting with Digester
Hi Gary,
The standard rules engine in Digester should support "*/menu" fine
(though it will not support "foo/*/menu" type patterns). The pattern
"*/menu" will match any menu tag, regardless of what its parentage is.
If this isn't good enough (ie you want to avoid matching menu tags which
are children of an XYZ tag) then you can probably use the
ExtendedBaseRules or RegexRules rules engines (see also doc for method
Digester#setRules).
Hope this helps,
Simon
On Tue, 2003-12-23 at 11:09, Gary Smart wrote:
> Hi.
>
> I can't manage to pattern match nested XML where the level of nesting
> is unknown (I'm only assuming that this can be done). Consider the
> following -
>
> An XML file used to create menu items in a Swing UI. <menu> elements
> can have an unlimited number of other <menu> elements. So for a menu
> structure like Tools|Options|Email, the XML would be similar to:
>
> <desktop>
> <menus>
> <menu> <-- Top Level Menu to be
installed
> on a JMenuBar
> <name>Tools</name>
> <menu> <-- Sub Menu installed under
> "Tools"
> <name>Options</name>
> <menu> <-- Sub Menu installed under
> "Options"
> <name>Email</name>
> </menu>
> </menu>
> <menu>
> </menus>
> </desktop>
>
> I tried the pattern "desktop/menus/*/menu" but Digestor logged "No
> rules found matching 'desktop/menus/menu'"/. Code is:
>
> digester.addObjectCreate("desktop/menus/*/menu",
> MenuInstaller.class);
> digester.addCallMethod("desktop/menus/*/menu/name",
> "setMenuName", 0);
>
>
> I also tried:
> desktop/menus/menu (This only captures the first menu (Tools),
as
> I expected)
>
> desktop/menus/*menu
> */menu (getting dsperate!)
> *menu (getting desperate!)
>
>
> Can this actually be done? Any help greatly appreciated.
>
> Thanks,
> Gary.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]