You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Marco Mistroni <mm...@waersystems.com> on 2004/05/14 16:05:32 UTC

Help with digester!

Hi all,
	I am experiencing problem with digester when I use
The xml files for the rules.

I have following SQL file :

<?xml version="1.0" encoding="UTF-8"?>
<sql>
  <statement>
     <name>getUsers</name>
     <value>select * from user_details</value>
  </statement>
  <statement>
     <name>getContact</name>
     <value>select *  from contact WHERE contact_ref = ? </value>
  </statement>
</sql>

I want, for each statement, to populate an Hashtable with name as key
and
Value as index.

When running normal digester and setting rules in java code
digester.addObjectCreate("sql", java.util.Hashtable.class);
			digester.addCallMethod("sql/statement",
"put",2);
			digester.addCallParam("sql/statement/name", 0);
			digester.addCallParam("sql/statement/value",1);
		} catch(Exception e) {

the problem is that either I don't know how to do the same in an xml
file
or my xml file for rules is incorrect.
I have tried with the following

<?xml version="1.0"?>
<digester-rules>
  <pattern value="sql">
      <object-create-rule classname="java.util.Hashtable" />
	   <set-properties-rule />
	   <call-method-rule pattern="statement" methodname="put"
             paramcount="2" />
              <call-param-rule pattern="statement/name"
paramnumber="0"/>
              <call-param-rule pattern="statement/value"
paramnumber="1"/>
     
  </pattern>
</digester-rules>

can anyone help?

Thanx in advance and regards
	Marco




---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: Help with digester!

Posted by José Antonio Pérez Testa <ja...@indra.es>.
It looks like everything is ok.
Look at the logs and see what's happening.
Maybe some problem with the arguments types. Try the method 
addCallMethod(String pattern, String methodName, int paramCount, 
String[] paramTypes)
and explicitly set the argument types. I've found a similar problem in 
calling ArrayList.add and it is because of the argument being 
java.lang.Object

Good luck.

Marco Mistroni wrote:

>Hi all,
>	I am experiencing problem with digester when I use
>The xml files for the rules.
>
>I have following SQL file :
>
><?xml version="1.0" encoding="UTF-8"?>
><sql>
>  <statement>
>     <name>getUsers</name>
>     <value>select * from user_details</value>
>  </statement>
>  <statement>
>     <name>getContact</name>
>     <value>select *  from contact WHERE contact_ref = ? </value>
>  </statement>
></sql>
>
>I want, for each statement, to populate an Hashtable with name as key
>and
>Value as index.
>
>When running normal digester and setting rules in java code
>digester.addObjectCreate("sql", java.util.Hashtable.class);
>			digester.addCallMethod("sql/statement",
>"put",2);
>			digester.addCallParam("sql/statement/name", 0);
>			digester.addCallParam("sql/statement/value",1);
>		} catch(Exception e) {
>
>the problem is that either I don't know how to do the same in an xml
>file
>or my xml file for rules is incorrect.
>I have tried with the following
>
><?xml version="1.0"?>
><digester-rules>
>  <pattern value="sql">
>      <object-create-rule classname="java.util.Hashtable" />
>	   <set-properties-rule />
>	   <call-method-rule pattern="statement" methodname="put"
>             paramcount="2" />
>              <call-param-rule pattern="statement/name"
>paramnumber="0"/>
>              <call-param-rule pattern="statement/value"
>paramnumber="1"/>
>     
>  </pattern>
></digester-rules>
>
>can anyone help?
>
>Thanx in advance and regards
>	Marco
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>  
>

-------------------------------------------------------------------------------------------------------------------
Este correo electr�nico y, en su caso, cualquier fichero anexo al mismo, contiene informaci�n de car�cter confidencial exclusivamente dirigida a su destinatario o destinatarios. Queda prohibida su divulgaci�n, copia o distribuci�n a terceros sin la previa autorizaci�n escrita de Indra. En el caso de haber recibido este correo electr�nico por error, se ruega notificar inmediatamente esta circunstancia mediante reenv�o a la direcci�n electr�nica del remitente.

The information in this e-mail and in any attachments is confidential and solely for the attention and use of the named addressee(s). You are hereby notified that any dissemination, distribution or copy of this communication is prohibited without the prior written consent of Indra. If you have received this communication in error, please, notify the sender by reply e-mail

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org