You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sundar Shanmugasundaram <SS...@SELECTICA.com> on 2001/09/27 13:47:47 UTC

Problem : Recursive elements in Digester

Hi All,
 
I have the following xml file :
<XYZ>
  <sections>
  <section id = "1">
  <displayName>FirstSec</displayName>
  <section id = "1.1">
   <displayName>Firstsub</displayName>
   <tableRef id="Master"/>
   <section id="1.1.1">
        <displayName>Firstsub11</displayName>
      <tableRef id="Master11"/>
   </section>
  </section>
  <section id = "1.2">
   <displayName>Firstsub2</displayName>
   <tableRef id="Master2"/>
   <section id="1.2.1">
        <displayName>Firstsub3</displayName>
      <tableRef id="Master3"/>
   </section>
  </section>
   </section>
   <section id = "2">
  <displayName>SecondSec</displayName>
  <tableRef id="Wood Finishes"/>
   </section>
    </sections>
</XYZ>
 
 
 
 I use the following methods :

   digester.addObjectCreate("XYZ/sections/section", "Section");
   Cat.debug("adding sections");
   digester.addSetProperties("XYZ/sections/section");
   digester.addSetNext("XYZ/sections/section", "addSection");
 
 
   digester.addObjectCreate("*/section", "Section");
   Cat.debug("adding sub sections");
   digester.addSetProperties("*/section");
   digester.addSetNext("*/section", "addSubSection");
 
 
I am not getting the desired results.  If I include the first one, I am
getting
section 1 and 2.  But If I use both I am getting no output.

I want to go through this section tag one by one.  Sometimes it 
goes straight into innermost node ( if i use */section only ).
Can you please provide me a sample code how to achieve this?
 
thanks,
sundar.