commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Sanders" <sand...@totalsync.com>
Subject Re: earth to digester
Date Fri, 02 Nov 2001 18:19:55 GMT
> > > Are you saying you want Castor's capabilities, at least on the
XML->Java
> > > side?
> >
> > I don't know exactly what Castor does, I've only looked at it for an
hour.
> >
> > > Something like on an element, try to find an attribute on the object
at the
> > > top of the stack that corresponds by name to that element, and set the
> > > attribute appropriately?
> >
> > The XML documents would probably have to attributes, all elements:
> >
> > <bean>
> >   <attribute1>value1</attribute1>
> >   <attribute2>value2</attribute2>
> > </bean>
> >
> > and
> >
> > bean.setAttribute1(value1)
> > bean.setAttribute2(value2)
> >
> > would be called. it obviously will get more complicated with nested
elements
> > but that's the general idea.
> >
>
> You can actually do this with Digester today:
>
>   digester.addObjectCreate("bean", "com.mycompany.MyClass");
>   digester.addCallMethod("bean/attribute1", "setAttribute1", 0);
>   digester.addCallMethod("bean/attribute2", "setAttribute2", 0);
>
> The "zero parameters" value is a (sort of) kludge that says "take the
> actual parameter value from the body of this element".
>
> It might be more concise to add some sort of a rule to make this easier to
> say, perhaps:
>
>   digester.addBeanPropertySetter("bean/attribute1");
>   digester.addBeanPropertySetter("bean/attribute2");
>
> that would infer the property name from the final element of the matching
> pattern, but it would be functionally equivalent to the existing
> capability.
>
>

Yes, he could do that, but I thought he was saying that he wanted Digester
to 'just know' to set the attribute, i.e. without defining specific rules.
Which way were you looking for Jason?

Scott


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message