Hi all,

I've got problems understanding the behaviour of a certain
case of xmlrules.

I want to digest a XML file with the following structure:

<foo>
  <bar>
    <baz>interesting content here</baz>
  </bar>
  <bar>
    <baz>some more content I want</baz>
  </bar>
</foo>

>From this I want to:

0. Creat a MyFoo container,
1. get all foo/bar/baz elements,
2. create a MyBaz bean for each such element,
3. fill it's field "content" from the character content of the the element
   using the bean's setContent() method,
4. and store the bean in the MyFoo instance using a method called addBaz().

The digester rules XML file I use is:

...
<digester-rules>
  <object-create-rule pattern="foo" classname="MyFoo"/>

  <pattern value="foo/bar/baz">
    <object-create-rule classname="MyBaz"/>
    <call-method-rule methodname="setContent" paramcount="0"/>
    <set-next-method methodname="addBaz"/>
  </pattern>
</digester-rules>

Unfortunatley this doesn't work. What happens is that 

0. The MyFoo container is created,
1. a foo/bar/baz element is encountered and
2. a new MyBaz instance is created which is
3. immediately added to MyFoo using the addBaz() method *after* which
4. the method setContent() of the MyBaz instance is called.

This leads to MyFoo containing only MyBaz instances with the content
field null.

My solution so far is to swap the <call-method-rule> and the
<set-next-rule> which results in the setContent() method of the MyBaz
instance being called *before* the addBaz() method of MyFoo is called.

Is this a bug or a feature or did I miss something?

Thanks
Lutz

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

Reply via email to