473,698 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using Jakarta Digester with unlimited nested elements - how?

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|E mail, 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.acti ons.EmailOption sAction</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.addObjectCrea te("desktop/menus/*/menu", MenuInstaller.c lass);
d.addCallMethod ("desktop/menus/*/menu/name", "setMenuNam e", 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.

Jul 17 '05 #1
0 1983

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2045
by: Brice Laurencin | last post by:
Good day everybody, The xml file looks like : <properties> <property> <name>fromEmail</name> <value env="dev">doty_alan@cat.com</value> <value env="test">doty_alan@cat.com</value> <value env="qa">capex_qa@cat.com</value> <value env="pord">capex@cat.com</value>
7
6841
by: codeslayer | last post by:
Greetings to everyone in ‘forum-land': I have a problem that has plaguing me to no end. It is a CSS-related question, and I have not seen this question posted anywhere in forums or through Google search. So here is my problem: I want to use CSS to apply images as bullet styles. However, I want to be able to apply VARIOUS, MULTIPLE styles in the same document. For example, let's assume I have a set of categorized hyperlinks on a...
2
1534
by: kevin_Eld | last post by:
I have the following xml: <message> <envelope> <body key="" value="" /> </envelope> </message> I have associated an xsd to this xml in order to use the XmlDataDocument and give me the
4
10755
by: August1 | last post by:
A handful of articles have been posted requesting information on how to use these functions in addition to the time() function as the seed to generate unique groups (sets) of numbers - each group consisting of 6 numbers - with a total of 50 groups of numbers. A well-known girl that some publishing companies use to provide introductory level textbooks to various Junior Colleges in the U.S., not surprisngly, asks for this same exact...
5
7400
by: Markus Ernst | last post by:
Hi I have a validation problem with a form and nested divs. I understand what the problem is, but I don't see how to fix it. This is my normal page structure, and it validates: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head>
46
9915
by: Neptune | last post by:
Hello. I am working my way through Zhang's "Teach yourself C in 24 hrs (2e)" (Sam's series), and for nested loops, he writes (p116) "It's often necessary to create a loop even when you are already in a loop." Then he goes on to portray a contrived example that doesn't tell me under what conditions a nested loop might be favoured as a solution? i.e. what are nested loops useful for? What kinds of algorithms are served by nested loops?...
30
6080
by: junky_fellow | last post by:
I was looking at the source code of linux or open BSD. What I found that lots of typedefs were used. For example, consider the offset in a file. It was declared as off_t offset; and off_t is typedefed as typedef long off_t; I wanted to know what advantage do we get by typedefs ? Why we did not declare
9
3905
by: sonal | last post by:
Hi all, I hv started with python just recently... and have been assigned to make an utility which would be used for data validations... In short we take up various comma separated data files for eg: area.txt, school.txt, students.txt.... and so on (ok?!?) now, 1. area code used in the school.txt must be defined in the area.txt (Primary key in area => area_code defined in area.txt & Foreign key on school => area_code defined in...
4
3515
by: Efi Merdler | last post by:
Hi, I have an xml file with the following structure: <Dictionary> .... <Nested> <Entry> .... </Entry> <Entry> ....
0
8600
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9155
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8890
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7711
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5859
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4614
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3038
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2322
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.