commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <>
Subject Re: [digester] RFE - Digester.startElement could use a callback
Date Wed, 15 Oct 2003 21:52:39 GMT
Hi Steve,

Are you saying that in the xml you are parsing, you expect to have at
least one Rule object defined for every XML element? And that you want
to know if there are any unexpected xml elements in the input so you can
report an error?

If this is the case, then an alternative solution is to create an xml
schema for your input, and validate against that schema.

I don't think many users of Digester will care whether an element has no
rules or not, ie your suggested feature is not likely to be used often.
So if there is a way to achieve what you want without adding any code it
would probably be desirable.

I do think that a generic "callback" mechanism for handling situations
where Digester encounters unusual situations or error situations may be
useful. There are several places where Digester throws an exception (see
calls to createSAXException) where it might be nice to invoke
caller-provided code ala org.xml.sax.ErrorHandler. If a mechanism were
to be added for this, then adding a callback for "no rules" might be
justified too; however I can't see adding a mechanism for *just* the "no
rules" case as being worth it....not enough people would want to use
this feature.

Of course if you can persuade people that your reason for wanting this
feature is one likely to be shared by other people, that would add a lot
of weight.

Anyone else got any thoughts on this?



PS: I'm not a committer/maintainer, just another interested user...

On Thu, 2003-10-16 at 06:38, Steve Drach wrote:
> Near the end of the startElement method, we see this:
>         List rules = getRules().match(namespaceURI, match);
>         if ((rules != null) && (rules.size() > 0)) {
>           ...
>         } else {
>             if (debug) {
>                 log.debug("  No rules found matching '" + match + "'.");
>             }
>         }
> It would be nice if I could register an interface implementation that
> contains a method that gets invoked in the else clause, so I can know
> if no rules match the name.  That way I can put out an error message if
> I want.  Somthing like this:
>         } else {
>             callback.notify(name);
>             if (debug) {
>                 log.debug("  No rules found matching '" + match + "'.");
>             }
>         }
> Of course, callback is not a very good name, but you get the idea.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message