The "commons.digester.CallMethodRule" is constructable with at least a
method name, i.e.

public CallMethodRule(java.lang.String methodName), see:

http://jakarta.apache.org/commons/digester/api/index.html


Furthermore, the docs go on to say:

"By using CallMethodRule(String methodName) a method call can be made to a
method which accepts no arguments."



So, why is this inconsistent with the "commons.digester.xmlrules"
counterpart -- that is, why is "paramcount" required by "call-method-rule"
in  "digester-rules.dtd"?

<!ELEMENT call-method-rule EMPTY>
<!ATTLIST call-method-rule
    pattern    CDATA #IMPLIED
    methodname CDATA #REQUIRED
    paramcount CDATA #REQUIRED>


Of course this causes Snippet.java (found below, instantiated with
QueryRules.xml, Queries.xml and Queries.java)  to throw
"java.lang.NumberFormatException: null".  And when I try working around it
by setting "paramcount" to say 1, the rule is ignored.

Why doesn't the "xmlrules" mirror "digester". Any ideas and help is greatly
appreciated.

Thanks in advance,

--Michael Marrotte


// Snippet.java
class MyDigester {
  File file = new File("/javatests/Queries.xml");
  Digester digester = new Digester();
  URL url;
  FromXmlRuleSet ruleSet;

  public void init() throws Exception{
    System.out.println("can read file = " + file.canRead());
    url = new URL("file:///javatests/QueryRules.xml");
    url.getContent();
    ruleSet =
    new FromXmlRuleSet(url);

    ruleSet.addRuleInstances(digester);

    System.out.println("rules = " + digester.getRules().rules());

    digester.push(this);

    digester.parse(file);

  }

// QueryRules.xml
<?xml version="1.0" encoding="UTF-8" ?>

<digester-rules>
        <object-create-rule pattern="*/query" classname="Queries"/>
        <set-properties-rule pattern="*/query"/>
        <call-method-rule pattern="*/query" methodname="addQuery"/>
 </digester-rules>

// Queries.xml
<?xml version="1.0" encoding="UTF-8" ?>
<queries>
<query lastName="Marrotte"/>
<query lastName="Luhrs"/>
</queries>


// Queries.java
public class Queries {
private String lastName = "";

public void setLastName(String lastName)
{
  this.lastName = lastName;
}
public String getLastName(){
  return lastName;
}

public void addQuery(){
  System.out.println("Add Query Here");
}

}


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to