I'll try to explain as far as my knowdledge of Digester and my english skills could.
My article of reference is O'Reilly's one :
http://www.onjava.com/lpt/a/2746
Frank Schaare wrote:
Hi,
i try to get familiar with the digester. Therefore i read all three (not very much) articles mentioned on digester�s homesite and tried some code like this:
public void initSQLRules() { try { Digester digester = new Digester(); digester.push(this);
Put 'this' on top of the stack.
digester.addObjectCreate("Abfragen",Abfragen.class);
When <Abfragen> is found create a new Abfragen object and put it on top of stack ( above 'this' )
digester.addObjectCreate("Abfragen/Abfrage",Abfrage.class);
When <Abfragen><Abfrage> is found create a new Abfrage object and put it on top of stack ( above the Abfragen instance )
digester.addBeanPropertySetter("Abfragen/Abfrage/Name","name");
When found the path "Abfragen/Abfrage/Name" call setter method 'setName()' on current stack top object ( that is the Abfrage instance)
passing the value taken from the xml element Name converted to the argument type of the setName method.
digester.addBeanPropertySetter("Abfragen/Abfrage/SQL","wert");
idem
digester.addSetNext("Abfragen/Abfrage","addAbfrage");
When </Abfrage> is found, remove current stack top object ( that is the Abfrage instance) and pass it as parameter to the addAbfrage() method of the actual
stack top object ( the Abfragen instance )
digester.parse("my.xml");
Tell digester to parse the file my.xml.
}
catch (Exception e)
{
e.printStackTrace();
}
}
This seems to work, what exactly happen here ? Obviously, the digester gets some rules an delegates xml parsing to a SAXParser.
Digester gets the rules that you are set in code
How do i access (get) the generatet Bean ?
if the Abfragen class has a method called public void addAbfrage(Abfrage beanObject) you will found your beans there. Otherwise Digester will write a log saying that it couldn't find the method
Where is the bean object createt ?
I think I've explained that above.
Who has information about this mysterios stack ?
If you enable tracing, you will get detailed information of what is going on during the parsing of the xml file.
The Code 'digester.push(this);' seems to put the servlet instance on a stack. What for ?
In order to keep track of the last object taken from the stack. You have to put another rule like
digester.addSetNext("Abfragen","addAbfragen");
and add that method
public void addAbfragen(Abfragen beanContainerObject)
to your servlet.
Digester will call it and pass the newly created Abfragen instance and you will have everything at your disposition.
Are there any sites that gain a little more information as jakarta does ?
thx for your answers.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
------------------------------------------------------------------------------------------------------------------- Este correo electr�nico y, en su caso, cualquier fichero anexo al mismo, contiene informaci�n de car�cter confidencial exclusivamente dirigida a su destinatario o destinatarios. Queda prohibida su divulgaci�n, copia o distribuci�n a terceros sin la previa autorizaci�n escrita de Indra. En el caso de haber recibido este correo electr�nico por error, se ruega notificar inmediatamente esta circunstancia mediante reenv�o a la direcci�n electr�nica del remitente.
The information in this e-mail and in any attachments is confidential and solely for the attention and use of the named addressee(s). You are hereby notified that any dissemination, distribution or copy of this communication is prohibited without the prior written consent of Indra. If you have received this communication in error, please, notify the sender by reply e-mail
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
