Thank you, Craig.Yep, addSetNext() is what I really meant :-). Your code looks good to go.
I dont know the "addCallNext" method you told about, but I think I have the
solution (?)
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:[EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
