I've used the RSS package to parse a RSS file, but haven't written any
of my own rules. To parse a RSS file, it goes like this:

/**
 * Read and parse RSS file found at a given
 * path, save the Channel bean in request scope,
 * and forward to "continue".
 * @expects path={uri} on command line or as parameter property to
ActionMapping.
 * @expects an input page or error forwarding if exception digesting RSS
 * @author Ted Husted
 * @version $Revision:1.1 $ $Date: 2000/09/05 $
 */
public final class Fetch extends Action {

    // ---------------------------------------------------------
Instances Variables
    // --------------------------------------------------------- Public
Methods

    /**
     * Request attribute key for saving Channel bean
     */
    public static final String CHANNEL_KEY = "CHANNEL";


    /**
     * Main process of class. Reads, parses
     */
    public ActionForward perform(ActionMapping mapping,
                                 ActionForm form,
                                 HttpServletRequest request,
                                 HttpServletResponse response)
        throws IOException, ServletException {

        ActionErrors errors = new ActionErrors();
        Channel channel = null;

        String path = request.getParameter("path");
        if (path==null) path = mapping.getParameter();
        try {
            RSSDigester digester = new RSSDigester();
            channel = (Channel) digester.parse(path);
        }
        catch (Throwable t) {
            errors.add(ActionErrors.GLOBAL_ERROR,
                new ActionError("rss.access.error"));
            servlet.log(t.toString());
        }

        // -- Handle Errors ---
        if (!errors.empty()) {
            saveErrors(request, errors);
            if (mapping.getInput()!=null)
                return (new ActionForward(mapping.getInput()));
            // If no input page, use error forwarding
            return (mapping.findForward("error"));
        }

        // -- Save Bean, and Continue  ---
        request.setAttribute(CHANNEL_KEY,channel);
        return (mapping.findForward("continue"));
    } // ---- End perform ----

} // ---- End Fetch ----

storck wrote:
> 
> Do you have used digister by your own?
> 
> -----Ursprungliche Nachricht-----
> Von: Ted Husted [mailto:archive@jab.org]
> Gesendet: Donnerstag, 20. September 2001 14:32
> An: [EMAIL PROTECTED]
> Betreff: Re: Digister
> 
> Look for the package.html file in the SOURCE distribution, or in the
> digester package in the 1.0 Struts source distribution.
> 
> For an example, look at the RSS package (and, well, Struts).
> 
> -- Ted Husted, Husted dot Com, Fairport NY USA.
> -- Custom Software ~ Technical Services.
> -- Tel +1 716 737-3463
> -- http://www.husted.com/about/struts/
> 
> storck wrote:
> >
> > HI,
> >
> > I try to use use digister from org.apache.commons.digester by my own but
> > without luck.
> > Does any doc exist to digister or any "How To" ?
> >
> > Thanks!

-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/about/struts/

Reply via email to