commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ceki Gülcü <>
Subject Possible documention glitch in commons-digester?
Date Tue, 14 May 2002 09:57:56 GMT


Looking at the source code of RulesBase.match(String, String) it can
be seen that wildcard matching is performed if there was no exact
match for the current pattern.

But the digester documentation (at

   It is quite possible that, when a particular XML element is being
   parsed, the pattern for more than one registered processing rule will
   be matched either because you registered more than one processing rule
   with the same matching pattern, or because one more more exact pattern
   matches and wildcard pattern matches are satisfied by the same

This statement is misleading because only when there is no exact match
for the current pattern are wildcard patterns taken into
consideration. (Also watch out for the "more more" typo.)

Here is a little experiment to make the case:

--- File ------------------

import org.apache.commons.digester.*;

public class EchoRule extends Rule {

   String pat;

   EchoRule(Digester digester, String pat) {
     this.pat = pat;

   public void body(String text) {
     System.out.println("Body of EchoRule("+pat+") called with text 

   public static void main(String[] args) throws Exception {

     Digester digester = new Digester();

     Rule aRule = new EchoRule(digester, "top/a");
     digester.addRule("top/a", aRule);

     Rule starARule = new EchoRule(digester, "*/a");
     digester.addRule("*/a", starARule);


Here is a test xml file called a1.xml

--- a1.xml --------

Try it out:

 > javac
 > java EchoRule a1.xml
Body of EchoRule(top/a) called with text [immediate].

You can also try it on a2.xml

--- a2.xml --------
       <a>embedded within b</a>

The result is:

 > java EchoRule a2.xml
Body of EchoRule(top/a) called with text [immediate].
Body of EchoRule(*/a) called with text [embedded within b].

In both tests you can see that EchoRule("*/a") is not called for


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

View raw message