Hi,

I struggled with this too for a while.  What works for me is to not enclose
the call-param-rules inside the call-method-rule.  So your rules file should
look like this... 

<call-method-rule pattern="parameter"
                   methodname="addParameter"
                   paramcount="2"/>
<call-param-rule paramnumber="0" attrname="name" />               
<call-param-rule paramnumber="1" attrname="value" />               
                 ^^^^^^^^^^^     ^^^^^^^^
You might also look at the dtd in the digester jar file.  This may give you
some hints.

-----Original Message-----
From: Lafredo, Stephen [mailto:[EMAIL PROTECTED]
Sent: Friday, March 21, 2003 4:17 PM
To: '[EMAIL PROTECTED]'
Subject: Digester: Cannot get <call-param-rule> to parse?


Hi,

I am using the commons-digester-1.4.1 and I am have used the digester
feeding it an xml rules file to parse my xml file and all works fine. Now I
am trying to define a method with parameters and I cannot seem to get the
syntax correct.

My xml file contains...

  <ResourceParams name="jdbc/db2">
    <parameter>
      <name>factory</name>
      <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
    </parameter>
    
    <!-- add remaining parameters here... -->
    
  </ResourceParams>

The corresponding portion of my rules file contains...

  <!-- Resource parameters are defined within the Context element and
       associated a Resource -->
  <pattern value="Context/ResourceParams">

    <object-create-rule
classname="org.apache.catalina.deploy.ResourceParams"
                        attrname="resourcesParameters"/>

    <!-- map the element's XML attributes to the bean properties -->
    <set-properties-rule>
      <alias attr-name="name" prop-name="name" />
    </set-properties-rule>

    <call-method-rule pattern="parameter"
                   methodname="addParameter"
                   paramcount="2">
      <call-param-rule param-index="0"
                    attribute-name="name" />               
      <call-param-rule param-index="1"      ^ - this is line 74, 45
                    attribute-name="value" />               
    </call-method-rule>                   

    <!-- add the ResourceParams to the Context -->
    <set-next-rule methodname="addResourceParams" />

  </pattern>
</digester-rules>

When I attempt to parse the file I receive these error messages...

Mar 21, 2003 5:02:42 PM org.apache.commons.digester.Digester startElement
SEVERE: Begin event threw exception java.lang.NumberFormatException: null
        at java.lang.Integer.parseInt(Integer.java:394)
        at java.lang.Integer.parseInt(Integer.java:476)
        at
org.apache.commons.digester.xmlrules.DigesterRuleParser$CallParamRuleFactory
.createObject(DigesterRuleParser.java:532)
        at
org.apache.commons.digester.FactoryCreateRule.begin(FactoryCreateRule.java:2
91) 


...and...


Application.start():  org.apache.commons.digester.xmlrules.XmlLoadException:
Error at (74, 45: null
        at
org.apache.commons.digester.xmlrules.FromXmlRuleSet.addRuleInstances(FromXml
RuleSet.java:165)
        at
org.apache.commons.digester.Digester.addRuleSet(Digester.java:1658)
        at
org.apache.commons.digester.xmlrules.DigesterLoader.createDigester(DigesterL
oader.java:90) 



I looked at line 74, 45 and it "appears" to be correct?

Does anyone have any recommendations or could you please point me to the
rules file syntax documentation.

Thank you.


Stephen Lafredo


----------------------------------------------------------------------------
--
Notice:  This e-mail message, together with any attachments, contains
information of Merck & Co., Inc. (Whitehouse Station, New Jersey, USA) that
may be confidential, proprietary copyrighted and/or legally privileged, and
is intended solely for the use of the individual or entity named in this
message.  If you are not the intended recipient, and have received this
message in error, please immediately return this by e-mail and then delete
it.

============================================================================
==


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

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

Reply via email to