commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gogineni, Pratima" <pgogin...@selectica.com>
Subject RE: Problem with Digester
Date Fri, 08 Apr 2005 06:39:20 GMT
Hi Veerendra,

Yes it is case sensitive. when you call addSetProperties. It is trying to
map the attributes of the "academy" element to the properties of the object
on top of the stack (instance of Academy). 

So the name of the attributes of the academy tag should be = property name
on the Academy object instance.

Since you have get/setUniqueId - based on java bean specification the
property name is uniqueID (YES case is important). which means your
attribute name on the academy element should be uniqueID.

Pratima

-----Original Message-----
From: Veerendra [mailto:veerendra@cassis-intl.com]
Sent: Thursday, April 07, 2005 11:34 PM
To: commons-user@jakarta.apache.org
Subject: Problem with Digester


Hi,
	I want to use digester frame work. I took some example from net
modified
for my testing, but when I am not getting the result as null. if I use
uniqueid instead of UniqueID in xml it is working. is that case sensitive.
Can some body pls help me.

Thank You,
Veerenrda

Here is my programs.

Test.xml :

<?xml version="1.0" encoding="UTF-8"?>
<gp:academy UniqueID="JAcademy"
xmlns:gp="http://namespaces.globalplatform.org/systems-profiles/1.1.0">
</gp:academy>


package com.tesdig;
import java.util.Vector;

public class Academy {
    private String UniqueID;

    public Academy() {
    }

    public String getUniqueID() {
        return UniqueID;
    }

    public void setUniqueID(String newUniqueID) {
        UniqueID = newUniqueID;
    }

    public String toString() {
        StringBuffer buf = new StringBuffer(60);

        buf.append("Academy UniqueID>> " + this.getUniqueID());

        return buf.toString();
    }
}


package com.tesdig;

import java.io.File;
import org.apache.commons.digester.Digester;

public class DigestJavaAcademy {
    public static void main(String[] args) throws Exception {
        DigestJavaAcademy d = new DigestJavaAcademy();
        d.digest();
    }

    public void digest() throws Exception {
        Digester digester = new Digester();
        digester.setNamespaceAware(true);

        digester.addObjectCreate("academy", Academy.class);

        //Set the attribute values as properties
        digester.addSetProperties("academy");

        //Parse the XML file to get an Academy instance
        File input = new File( "academy.xml" );
        Academy a = (Academy) digester.parse(input);
        System.out.println(a);
    }
}


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

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


Mime
View raw message