| -----Original Message-----
| From: Simon Kelly [mailto:[EMAIL PROTECTED]]
| Sent: Thursday, January 16, 2003 2:07 AM
| To: Struts Users Mailing List
| Subject: Complete tutorial on Digester?
| 
| Hi,
| 
| Does any one know of a good, complete, tutorial on Digester and all
it's
| uses?  I've got a couple of small example based ones but they don't
really
| deal with the more complex xml structures or how to handle recursion
| within
| xml.

JavaWorld (close enough)
http://www.javaworld.com/javaworld/jw-10-2002/jw-1025-opensourceprofile.
html

Recursion is handled by specifying leading "*/tagName" in your path
specifications.  I used it in my CacheFilter implementation that allows
you to setup trees of caches via the Composite Pattern.

// from my ServletCacheRuleSet extends RuleSetBase
public void addRuleInstances(Digester digester)
{       
        digester.addObjectCreate("*/cache", "type",
CompositeServletCache.class);
        digester.addSetProperties("*/cache");
        digester.addSetNext("*/cache", "addServletCache");
}

// from my ServletCacheConfig (this.rules is a ServletCacheRuleSet)
public ServletCache createCache(InputSource inputSource) throws
IOException, SAXException
{
        ServletCache cache = this.createCache();
                
        Digester digester = new Digester();
        this.rules.addRuleInstances(digester);
        digester.push(cache);
        
        digester.parse(inputSource);
        
        return cache;
}

For more complex examples, check out Strut's source code, Craig or
whomever wrote all the configuration/setup procedures with Digester.

-Jacob Hookom

| 
| Cheers
| 
| Simon
| 
| Institut fuer
| Prozessdatenverarbeitung
| und Elektronik,
| Forschungszentrum Karlsruhe GmbH,
| Postfach 3640,
| D-76021 Karlsruhe,
| Germany.
| 
| Tel: (+49)/7247 82-4042
| E-mail : [EMAIL PROTECTED]
| 
| 
| --
| To unsubscribe, e-mail:   <mailto:struts-user-
| [EMAIL PROTECTED]>
| For additional commands, e-mail: <mailto:struts-user-
| [EMAIL PROTECTED]>


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

Reply via email to