commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carsten Kaiser" <Carsten.Kai...@valtech.de>
Subject AW: DIGESTER/XML-RULES: Accessing attributes in a call-method-rule
Date Mon, 18 Apr 2005 10:41:57 GMT


-----Urspr√ľngliche Nachricht-----
Von: rafiq@dreamthought.com [mailto:rafiq@dreamthought.com]
Gesendet: Montag, 18. April 2005 12:06
An: skitching@apache.org
Cc: Jakarta Commons Users List
Betreff: Re: DIGESTER/XML-RULES: Accessing attributes in a
call-method-rule


Hi Simon,
...
> [snip]
>> The problem is that I haven't figured out and can't find refernce of how
>> or even 'if' it is possible to refer to attributes in my pattern.  xpath
>> style /path/to/@attribute don't seem to work and thus I'd like help in
>> figuring out how to do the following illegal bit of digesting:
>
> No, there is no way to refer to attributes in the "pattern" associated
> with a rule. It would indeed be nice to have this, but no-one has
> implemented this, and it is not trivial. There was a proposal to add
> "filters" to rules, so that once a pattern matched, the associated rule
> might still be skipped if the "filter" failed (eg if a required
> attribute was not present or did not match the required value). This
> does look easier to implement than attribute-matching support in rule
> patterns. However this has not been implemented either.
>
> I do hope that digester 2.x will have such a feature. However that's
> still vapourware at the current time.

Thanks for the clarification.

> The call-method-rule entry determines what method will be called, and on
> what object (the top object on the stack at the time the
> call-method-rule matches the input xml). However the parameters that are
> passed to the target method are generally selected via call-param-rule
> entries - and call-param-rule *can* select attributes from the matching
> xml element.
>

ok.  exactly what I'm after.

Many thanks for clearing things up.

> By the way, I think the xmlrules module sucks. I believe Digester is
> much easier to understand when you use the Digester java API directly.
Hallo Raf,

why don't you use a factory create rule in combination with your own abstract object creation
factory implementation? This works fine with the XML rules and you have complete control over
all attributes...

When <something> is parsed it permits you to access its attributes via a_attributes.getQName(i)
and 
a_attributes.getName(i), thus you are able to call BeanUtils.setProperty() or PropertyUtils.setProperty()
to populate the properties of your newly created instance...


Regards,
CK

Me too.  I'm trying to 'maintain the conventions' of the code base which
I'm currently extending.  It just so happens that it has extensively used
xmlrules.

> automatically converted to a java.util.Date object you will need to
> register an appropriate converter object using
>   ConvertUtils.register(..)
> See the BeanUtils library documentation for info on this.

Right.  I figured as much.

Many Thanks,

Raf



---------------------------------------------------------------------
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