commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Qaiser Mehmood" <Qaiser.Mehm...@revolution.com>
Subject help for Commenos Digester
Date Tue, 11 Apr 2006 17:28:39 GMT
Hi,

 

I am using Commons Digester to parse one XML file to a Java Object and
the code is not populating my Java Bean. The XML Files are 

 

Rules.xml :

 

<?xml version="1.0"?>

 

<digester-rules>

  

 <pattern value="messages/message">

            <object-create-rule
classname="com.rhg.infrastructure.dao.bean.Message" />

            <set-next-rule methodname="add"
paramtype="java.lang.Object"/>

            <set-properties-rule />

            <bean-property-setter-rule pattern="application_name"/>

            <bean-property-setter-rule pattern="createDate"/>

            <bean-property-setter-rule pattern="createdBy"/>

            <bean-property-setter-rule pattern="id"/>

            <bean-property-setter-rule pattern="index_page"/>

            <bean-property-setter-rule pattern="message_text"/>

            <bean-property-setter-rule pattern="priority"/>

            <bean-property-setter-rule pattern="signature"/>

            <bean-property-setter-rule pattern="user_id"/>

            

  </pattern>

</digester-rules>

 

Test.xml :

 

<?xml version="1.0" ?>  

 <messages>

  <message>

    <application_name>Find Doc</application_name>

    <createDate>2006-04-11 09:48:22.406</createDate>

    <createdBy>1</createdBy>

    <id>0</id>

    <index_page>index.jsp</index_page>

    <message_text>Error on Index.jsp</message_text>

    <priority>5</priority>

    <signature>Revolution Team</signature>

    <user_id>1</user_id>

  </message>

 </messages>

 

And the code :

 

List messagesList = new ArrayList( );

URL rules = getClass( ).getResource("/rules.xml");

Digester digester = DigesterLoader.createDigester(rules);

digester.push(messagesList);

InputStream input = getClass( ).getResourceAsStream("/test.xml");

Object root = digester.parse(input);

message = (Message) messagesList.get(0);

 

 System.out.println("message application name "+message);

 

There are elements in messageList , bu the fileds in message are null.
So Field from the 2nd XML file are not populated. Any help. I will
appreciate prompt response.

 

Qaiser Mehmood


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message