commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ra...@dreamthought.com
Subject DIGESTER/XML-RULES: Accessing attributes in a call-method-rule
Date Fri, 15 Apr 2005 19:51:40 GMT
Dear All,

I have a tree fragment looking a little like:

<something somename="12" somedate="2005-03-15" sometruth="true"
somearray="[foo,bar]"/>

Using xml rules I am trying to populate something like:
public class foo {
        private Vector somearray;
        private Date somedate;
        private String somename;
        // setters/accessors etc
}

Now in my digester rules I have the issue that due to the type differences
between the somearray - which I don't care about - and my xml
representation - any calls to <set-properties-rules/> seem to give me type
exceptions.  To circumvent this, and given that I'm only interested in the
somedate and sometruth attributes, I tried to use the call-method-rule. 
It's also perfect since I can specify the types to cast to.

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:

<pattern "*/something">
   <object-create-rule classname="bar.foo"/>
   <call-method-rule pattern="*/@somename" methodname="setName"
paramcount="0" paramtypes="java.lang.String"/>
   <call-method-rule pattern="*/@somedate" methodname="setDate"
paramcount="0" paramtypes="java.util.Date"/>
</pattern>

Or something which will let me have the flexibility of call-method-rule
when setting my attributes.

I'm new to digester/xml-rules and am trying really hard not to curse and
just go back to writing my own sax handlers.

Either way, I'd be very grateful to anyone able to show me the light here.

Cheers,

Raf




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