On Tuesday, April 30, 2002, at 05:24  PM, Craig R. McClanahan wrote:

>
>
> On Tue, 30 Apr 2002, Vijay Arokayaraj wrote:
>
>> Date: Tue, 30 Apr 2002 05:18:39 -0700
>> From: Vijay Arokayaraj <[EMAIL PROTECTED]>
>> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>,
>>      [EMAIL PROTECTED]
>> To: [EMAIL PROTECTED]
>> Subject: Help required on Digester class
>>
>> Hi all,
>> I am new to struts. My question is do we have to use the Digester 
>> class to actually read any of the XML files? If so how do I actually 
>> map an XML file into a class object (class here represents a model) 
>> when the XML file has got multiple elements in them and is not 
>> attribuite oriented . For example
>>
>> <?xml version="1.0"?>
>>       <user>
>>             <name>vijay</name>
>>              <mail>[EMAIL PROTECTED]</mail>
>>        </user>
>>
>
> One way to do this would be to define a Digester rule for each nested
> property name:
>
>   digester.addObjectCreate("user", "com.mycompany.MyUserClass");
>   digester.addCallMethod("user/name", "setName", 0);
>   digester.addCallMethod("user/mail", "setMail", 0);

Yup. This works fine. Digester is a great tool! One thing I'm looking at 
is how to combine it with a set of regular expression rules for the 
elements and attributes. Something like:

  <command id="123">
    <user username="stefan"/>
  </command>

With a property list:

  command.id=/^\d+$/
  user.username=/^[a-z0-9]+$/

And make this part of the validation process. I'm interested in your 
thoughts about this. Is this something to add to the Digester core code 
or something that I should move to my own classes?

  Stefan


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to