Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.1
    • Fix Version/s: None
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

      Description

      Hi,

      I have this problem when using Digester to parse my XML file.
      Suppose we have the following XML structure:

      <parent>
      firstPart
      <child>
      child1
      </child>
      secondPart
      <child>
      child2
      </child>
      lastPart
      </parent>

      The corresponding DTD structure would be:

      <!ELEMENT parent (#PCDATA | child)*>
      <!ELEMENT child (#PCDATA)>

      I saw that the body() method of a Rule object is called only when the end
      of the matching pattern is encountered, and that's why we can only retrieve
      the "lastPart" portion of the <parent> element body, presented in the
      previous example.
      Even more, in such a case, the body() method would receive "child2lastPart"
      as parameter.
      I think this is because we assumed that an element would never have split
      body content like the one I constructed.

      I propose a solution in witch to call the body() method of a rule
      on characters() event of the matching element pattern,
      rather than on endElement(), in order to be able to treat all the body chunks.

      What do you think about this ?

      Thanks!

      Best regards,
      Teodor Danciu

        Activity

        Hide
        Simon Kitching added a comment -

        I believe this was a bug fixed in v1.27 of Digester.java on 2001/11/14, and
        no-one has replied otherwise, so marking this as fixed.

        Show
        Simon Kitching added a comment - I believe this was a bug fixed in v1.27 of Digester.java on 2001/11/14, and no-one has replied otherwise, so marking this as fixed.
        Hide
        Simon Kitching added a comment -

        I believe this was a bug fixed in v1.27 of Digester.java on 2001/11/14.

        Can this therefore be closed?

        In the patch, line
        bodyText.setLength(0)
        was replaced by
        bodyText = new StringBuffer()

        preventing text data in child elements from clearing data from bodyText objects
        on the bodyTexts stack.

        The result matches Emmanuel Bourg's case#1 which seems to me at least to be the
        proper behaviour.

        Robert, are you implying with your comments here that you see a reason to
        implement any of the other options suggested by Emmanuel?

        Show
        Simon Kitching added a comment - I believe this was a bug fixed in v1.27 of Digester.java on 2001/11/14. Can this therefore be closed? In the patch, line bodyText.setLength(0) was replaced by bodyText = new StringBuffer() preventing text data in child elements from clearing data from bodyText objects on the bodyTexts stack. The result matches Emmanuel Bourg's case#1 which seems to me at least to be the proper behaviour. Robert, are you implying with your comments here that you see a reason to implement any of the other options suggested by Emmanuel?
        Hide
        rdonkin@apache.org added a comment -

        digester 1.4.1 released

        Show
        rdonkin@apache.org added a comment - digester 1.4.1 released
        Hide
        rdonkin@apache.org added a comment -

        after 1.4.1 release

        Show
        rdonkin@apache.org added a comment - after 1.4.1 release
        Hide
        rdonkin@apache.org added a comment -

        drat - selected wrong option!

        Show
        rdonkin@apache.org added a comment - drat - selected wrong option!
        Hide
        rdonkin@apache.org added a comment -

        after 1.4.1 release

        Show
        rdonkin@apache.org added a comment - after 1.4.1 release
        Hide
        rdonkin@apache.org added a comment -

        digester 1.4 released

        Show
        rdonkin@apache.org added a comment - digester 1.4 released
        Hide
        rdonkin@apache.org added a comment -

        changing this behaviour would break compatibility and therefore isn't going to
        happen any time soon.

        it may be possible to modify some of the interfaces so that rules but this isn't
        going to happen for this upcoming release.

        since this has been hanging around for ages, i may look at the possibilities
        after this release

        Show
        rdonkin@apache.org added a comment - changing this behaviour would break compatibility and therefore isn't going to happen any time soon. it may be possible to modify some of the interfaces so that rules but this isn't going to happen for this upcoming release. since this has been hanging around for ages, i may look at the possibilities after this release
        Hide
        Emmanuel Bourg added a comment -

        What value should be expected for the body of the parent element in this case ?
        (modulo spaces and line returns)
        1) "firstPart secondPart lastPart"
        2) "firstPart child1 secondPart child2 lastPart"
        3) "firstPart <child>child1</child> secondPart <child>child2</child> lastPart"

        Show
        Emmanuel Bourg added a comment - What value should be expected for the body of the parent element in this case ? (modulo spaces and line returns) 1) "firstPart secondPart lastPart" 2) "firstPart child1 secondPart child2 lastPart" 3) "firstPart <child>child1</child> secondPart <child>child2</child> lastPart"

          People

          • Assignee:
            Unassigned
            Reporter:
            Teodor Danciu
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development