commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig McClanahan <craig...@apache.org>
Subject Re: [DIGESTER] Newbie question
Date Sun, 04 Apr 2004 17:07:57 GMT
Richard HALLIER wrote:

>Thank you, Craig.
>
>I dont know the "addCallNext" method you told about, but I think I have the
>solution (?)
>  
>
Yep, addSetNext() is what I really meant :-).  Your code looks good to go.

Craig

>		UIResource ui,tmp=new UIResourceImpl();
>		Digester d = new Digester();
>
>		d.setValidating(false);
>
>		d.push(tmp);
>		d.addObjectCreate("*/resource", UIResourceImpl.class);
>		d.addSetProperties("*/resource");
>
>		d.addObjectCreate("*/locator",UIResourceLocatorImpl.class);
>		d.addSetProperties("*/locator");
>		d.addSetNext("*/locator","setLocator");
>
>		d.addSetNext("*/resource","addResource");
>
>		try
>		{
>			d.parse(fileName);
>		}
>		catch(Exception e)
>		{
>			log.error("Unable to parse the xml file "+fileName,e);
>		}
>
>		ui=(UIResource)tmp.getChildren().iterator().next();
>		ui.setParent(null);
>
>Richard
>-----Message d'origine-----
>De : Craig McClanahan [mailto:craigmcc@apache.org]
>Envoyé : dimanche 4 avril 2004 00:42
>À : Jakarta Commons Users List
>Objet : Re: [DIGESTER] Newbie question
>
>
>Richard HALLIER wrote:
>
>  
>
>>Hi all,
>>I've a simple problem, and I cant manage to resolve it, what are the
>>digester rules for the follwing reccurent pattern :
>>
>><ressource type="page" id="item.entite">
>>	<locator type="label" value="zobilamouche"/>
>>	<ressource type="form" id="formID">
>>		<locator type="name" value="entityForm"/>
>>	</ressource>
>></ressource>
>>
>>I've added the following methods to the Ressouce class :
>>addRessource(Ressource re) and setParent(Ressource re)
>>
>>Thank you for your precious help.
>>
>>Richard
>>
>>
>>    
>>
>You can use patterns like "*/ressource" and "*/locator" to match those
>elements, no matter how deeply they are nested.  So, you might have
>rules like this:
>
>  digester.addObjectCreate("*/ressource", "com.mycompany.Ressource");
>  digester.addSetProperties("*/ressource");
>  digester.addCallNext("*/ressource", "com.mycompany.Ressource");
>
>(I would have the call to setParent() happen inside the addRessource()
>method, instead of requiring both to be done by Digester rules).
>
>Because these rules will be fired for even the outermost <ressource>
>element, you'll want to push a Ressource object onto the digester stack
>before you start parsing.
>
>Craig
>
>PS:  If "ressource" is supposed to be in English, it's actually spelled
>"resource".
>
>
>---------------------------------------------------------------------
>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
>  
>


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