Commons Digester
  1. Commons Digester
  2. DIGESTER-20

CallMethod rule on nested indentical elements cause parameter confusion

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Nightly Builds
    • Fix Version/s: None
    • Labels:
      None
    • Environment:

      Operating System: other
      Platform: Other

      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>

      1. ASF.LICENSE.NOT.GRANTED--CallParamRule.patch
        1.0 kB
        Emmanuel Bourg
      2. ASF.LICENSE.NOT.GRANTED--RuleTestCase.patch
        1 kB
        Emmanuel Bourg
      3. ASF.LICENSE.NOT.GRANTED--Test8.xml
        0.1 kB
        Emmanuel Bourg

        Activity

        Henri Yandell made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Henri Yandell made changes -
        Affects Version/s Nightly Builds [ 12311810 ]
        Henri Yandell made changes -
        Assignee Jakarta Commons Developers Mailing List [ commons-dev@jakarta.apache.org ]
        Affects Version/s Nightly Builds [ 12311648 ]
        Component/s Digester [ 12311111 ]
        Key COM-138 DIGESTER-20
        Project Commons [ 12310458 ] Commons Digester [ 12310471 ]
        Henri Yandell made changes -
        Field Original Value New Value
        issue.field.bugzillaimportkey 11693 12340289
        Emmanuel Bourg created issue -

          People

          • Assignee:
            Unassigned
            Reporter:
            Emmanuel Bourg
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development