Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
Nightly Builds
-
None
-
None
-
Operating System: other
Platform: Other
-
11693
Description
There's a problem with the CallMethodRule rule using an attribute as parameter
and matching nested identical elements : the parameter for the last rule matched
(and the first method call actually done) is used for all previous calls.
For example, with this XML file :
<?xml version="1.0"?>
<toplevel>
<foo bar="A">
<foo bar="B">
<foo bar="A">
<foo bar="D">
<foo bar="C">
<foo bar="B">
<foo bar="A"/>
</foo>
</foo>
</foo>
</foo>
</foo>
</foo>
</toplevel>
If the "bar" attribute of all "foo" elements is appended to a StringBuffer :
StringBuffer sequence = new StringBuffer();
digester.push(sequence);
digester.addCallMethod("*/foo", "append", 1);
digester.addCallParam("*/foo", 0, "bar");
the result of sequence.toString() is "AAAAAAA" instead of "ABCDCBA".
It works fine with body content used as parameter instead of attributes
<?xml version="1.0"?>
<toplevel>
<foo>A
<foo>B
<foo>A
<foo>D
<foo>C
<foo>B
<foo>A
</foo>
</foo>
</foo>
</foo>
</foo>
</foo>
</foo>
</toplevel>
digester.addCallMethod("*/foo", "append", 0);
It's also fine with different elements :
<?xml version="1.0"?>
<toplevel>
<foo1 bar="A">
<foo2 bar="B">
<foo3 bar="A">
<foo4 bar="D">
<foo5 bar="C">
<foo6 bar="B">
<foo7 bar="A"/>
</foo6>
</foo5>
</foo4>
</foo3>
</foo2>
</foo1>
</toplevel>