Xerces2-J
  1. Xerces2-J
  2. XERCESJ-37

setIgnoringComments does not seem to work

    Details

    • Type: Bug Bug
    • Status: Open
    • Resolution: Unresolved
    • Affects Version/s: 2.0.0 [beta 2]
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      Operating System: All
      Platform: All

      Description

      The setIgnoringComments method of DocumentBuilderFactory does not seem to work!

      First, it is a little unclear exactly what this method is supposed to do. The
      skimpy javadocs simply state:
      "Specifies that the parser produced by this code will ignore comments"

      Well, what does "ignore comments" PRECISELY mean?

      I ASSUME that it means that whenever the parser hits a comment in the xml
      document, it will ignore it as if it were never in the document.

      Consider this document fragment:
      <someElement>
      blah blah blah
      <!-- comment, should be ignored -->
      more blahs
      </someElement>

      If my interpretation of "ignoring comments" is correct, then the <someElement>
      tag should have precisely 1 child Node, a Text node to be specific.

      If you adopt a slightly looser interpretation of "ignore comments", then maybe
      the parser might initially produce 2 child Text Nodes for <someElement>. In
      this case, if you call on someElement's normalize method when working with the
      DOM view of the document, it should coalesce the 2 child Text nodes into 1.

      In reality, I see neither of the above behaviors. Instead, all 3 child Nodes of
      the original document are present in the DOM view (a Text Node, then Comment
      Node, then the final Text Node). Here, I am using the default parser (i.e.
      Xerces 2.0.0 beta 2).

      I assume that the above behavior is a bug.

      Regardless of whether or not it is a bug, the javadocs for the method need
      considerable more fleshing out.

        Activity

        Hide
        Rahul Srivastava added a comment -
            • Bug 4769 has been marked as a duplicate of this bug. ***
        Show
        Rahul Srivastava added a comment - Bug 4769 has been marked as a duplicate of this bug. ***
        Hide
        Edwin Goei added a comment -

        Yes, I agree the setIgnoringComments() method in JAXP isn't that well defined
        and may not be even be implemented in parsers that expose JAXP APIs. I'd
        recommend that you not use this feature and do the filtering at the application
        level above DOM so that you app will be more parser independent.
        edwingo@apache.org

        Show
        Edwin Goei added a comment - Yes, I agree the setIgnoringComments() method in JAXP isn't that well defined and may not be even be implemented in parsers that expose JAXP APIs. I'd recommend that you not use this feature and do the filtering at the application level above DOM so that you app will be more parser independent. edwingo@apache.org

          People

          • Assignee:
            Unassigned
            Reporter:
            Brent Boyer
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Development