Shouldn't it be ?
digester.addBeanPropertySetter
("students/student/[EMAIL PROTECTED]'name']/@value", "name");
digester.addBeanPropertySetter
("students/student/[EMAIL PROTECTED]'course']/@value", "course");
digester.addBeanPropertySetter
("students/student/[EMAIL PROTECTED]'age']/@value", "age");If not, we may try to set property value to property named "value" ----------------------------------- Diogo Bacelar Quintela EF - Tecnologias de Informação, Lda. Av. António Serpa, 26 - 4º Dto. 1050-027 Lisboa, Portugal Tel: (+351) 217 827 800 Fax: (+351) 217 827 830 Email: [EMAIL PROTECTED] PGP: 0xF51A5AB9 > -----Original Message----- > From: Valerio Schiavoni [mailto:[EMAIL PROTECTED] > Sent: quarta-feira, 28 de Dezembro de 2005 17:05 > To: Jakarta Commons Users List > Subject: Re: [digester] different xml, same objective ? > > Hello Russel, > i did try using this code: > digester.addBeanPropertySetter > ("students/student/[EMAIL PROTECTED]'name']/@value"); > digester.addBeanPropertySetter > ("students/student/[EMAIL PROTECTED]'course']/@value"); > digester.addBeanPropertySetter > ("students/student/[EMAIL PROTECTED]'age']/@value"); > > (i think you forgot a '@' before the name), but it doesn't build the > Student > object properly. > this is the output i get: > > Using studentXML1: Students List [Name=Java Boy & Course=JSP & Age=10] > Using studentXML2: Students List [Name=null & Course=null & Age=0] > > where you can see that fields are not set properly. > > > 2005/12/28, Russell Simpkins <[EMAIL PROTECTED]>: > > > > given > > > > > protected String studentsXML2 = "<?xml version=\"1.0\"?>" > > > + "<students>" > > > + "<student>" > > > + "<property name=\"name\" value=\"Java Boy\"/>" > > > + "<property name=\"course\" value=\"Digester\"/>" > > > + "<property name=\"age\" value=\"10\"/>" > > > + "</student>" > > > + "</students>"; > > > > > > public void testAddBeanPropertySetter1() { > > > > > > DigestStudents ds = new DigestStudents(studentsXML1); > > > ds.digest(); > > > > > > } > > > > > > public void testAddBeanPropertySetter2() { > > > > > > DigestStudents ds = new DigestStudents(studentsXML2); > > > ds.digest(); > > > > > > } > > > > > > private class DigestStudents { > > > List<Student> students; > > > String input; > > > public DigestStudents(String input) { > > > > > > students = new ArrayList<Student>(); > > > this.input = input; > > > } > > > > > > private void digest() { > > > try { > > > Digester digester = new Digester(); > > > digester.setRules(new ExtendedBaseRules()); > > > > > > digester.push(this); > > > > > > digester.addObjectCreate("students/student", > > >Student.class); > > > > > > digester.addBeanPropertySetter("students/student/?"); > > > > did you try: > > > > digester.addBeanPropertySetter > > ("students/student/property[name='name']/@value"); > > digester.addBeanPropertySetter > > ("students/student/property[name='course']/@value"); > > digester.addBeanPropertySetter > > ("students/student/property[name='age']/@value"); > > > > which is the XPath way to grab those property values > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > -- > To Iterate is Human, to Recurse, Divine > James O. Coplien, Bell Labs
smime.p7s
Description: S/MIME cryptographic signature
