aspose file tools*
The moose likes Other Open Source Projects and the fly likes Digester Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Digester Problem" Watch "Digester Problem" New topic
Author

Digester Problem

Neha Kathuriaa
Greenhorn

Joined: Sep 16, 2008
Posts: 25
Hi
I have to create a simple digester class .I tried the following example given on Apache site.
Foo.java
package mypackage;
public class Foo {
public void addBar(Bar bar);
public Bar findBar(int id);
public Iterator getBars();
public String getName();
public void setName(String name);
}
Bar.java
package mypackage;
public class Bar {
public int getId();
public void setId(int id);
public String getTitle();
public void setTitle(String title);
}
and you wish to use Digester to parse the following XML document:
<foo name="The Parent">
<bar id="123" title="The First Child"/>
<bar id="456" title="The Second Child"/>
</foo>
A simple approach will be to use the following Digester in the following way to set up the parsing rules, and then process an input file containing this document:

Digester digester = new Digester();
digester.setValidating(false);
digester.addObjectCreate("foo", "mypackage.Foo");
digester.addSetProperties("foo");
digester.addObjectCreate("foo/bar", "mypackage.Bar");
digester.addSetProperties("foo/bar");
digester.addSetNext("foo/bar", "addBar", "mypackage.Bar");
Foo foo = (Foo) digester.parse();
This was working for me. Now I want to create a digester class which can read tags from xml file. But I don't want to give the matching patterns like this digester.addObjectCreate("foo", "mypackage.Foo");I want to read all the custom tags in xml in generakized manner.Can anybody give me a solution to this?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Digester Problem
 
Similar Threads
Jakarta commons Digester
How to implemen commons.digester in Servlet
Digester "aggressive mapping" Config Question
Collections-usage design review
Connection Pooling : Does anybody have connection pooling code in jsp?