Using Jakarta Digester with unlimited nested elements - how?
From: Gary Smart (gary_smart_at_acslink.net.au)
Date: 12/22/03
- Next message: Anthony Borla: "Re: Array Question"
- Previous message: Silvio Bierman: "Re: jsp for IIS"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 22 Dec 2003 00:09:10 GMT
Hello.
I've been searching news groups and apache and google, but can't solve
this one:
I have an XML file used to create menu items in a Swing UI. I have a
<menu> element that 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>
<action>au.com.smarttours.actions.EmailOptionsAction</action>
</menu>
<menu>
</menus>
</desktop>
The <action> becomes the "Email" menu item.
I've been trying to use Jakarta Commons Digestor to parse the XML, but
cannot get it to successfully capture the nested <menu> elements. I've
tried the following with no success (d is a Digester instance):
d.addObjectCreate("desktop/menus/*/menu", MenuInstaller.class);
d.addCallMethod("desktop/menus/*/menu/name", "setMenuName", 0);
d.addCallMethod("desktop/menus/*/menu/before", "addBefore", 0);
d.addCallMethod("desktop/menus/*/menu/after", "addAfter", 0);
I thought this would work, but Digester logs "No rules found matching
'desktop/menus/menu'"
Other tried variations include:
desktop/menus/menu (This only captures the first menu (Tools), as I
expected)
desktop/menus/*menu
*/menu (getting dsperate!)
*menu (getting desperate!)
The project has been using Digester for other (non-unlimited-nesting)
xml parsing successfully, so I'm trying to continue using it before
having to switch to JDOM or JAXP or something else. I reasonably suspect
that Digestor should be able to handle this?
Any help or suggestions would be greatly appreciated.
Thanks,
Gary.
- Next message: Anthony Borla: "Re: Array Question"
- Previous message: Silvio Bierman: "Re: jsp for IIS"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|