Menu

#20 Support for XML entities comparison

closed-fixed
nobody
5
2008-04-19
2008-01-22
No

The DifferenceEngine's JavaDoc ( http://xmlunit.sourceforge.net/api/org/custommonkey/xmlunit/DifferenceEngine.html ) indicates: "Nodes of other types (eg ENTITY_NODE) will be skipped."

This means that for example this test case fails:

assertXMLEqual("<root>bla\r\nbla</root>", "<root>bla&#xD;\nbla</root>");

I suppose this is because XmlUnit sees \r\n on one side and only \n on the other side since &#xD; is skipped.

In my case the control and the test are generated by different processing chain (and XML parsers/serializers), which may produce either entities or standard characters.

XMLUnit.setNormalizeWhitespace(true); seems to be a solution for the special case of this entity, but
true support for XML entities comparison would be much better.

Discussion

  • Stefan Bodewig

    Stefan Bodewig - 2008-02-28
    • labels: --> XMLUnit for Java
     
  • Stefan Bodewig

    Stefan Bodewig - 2008-04-04

    Logged In: YES
    user_id=113148
    Originator: NO

    If I change your example to

    assertXMLEqual("<root>bla1\nbla</root>", "<root>bla&#x31;\nbla</root>");

    it passes for me, so there is something strange with the expansion of a carriage return.

    My reading of EntityReference's Javadocs

    "Note that character references and references to predefined entities are considered to be expanded by the HTML or XML processor so that characters are represented by their Unicode equivalent rather than by an entity reference."

    is that we can rely on the parser to expand simple character references and my test with "1" -> "&#x31; seems to confirm this.

    If I use &quot; and \" it fails, again.

    I'll throw in a property for XMLUnit that invokes DocumentBuilderFactory.setExpandEntityReferences for more control, we'll see how that works out.

     
  • Stefan Bodewig

    Stefan Bodewig - 2008-04-04
    • status: open --> pending-fixed
     
  • Stefan Bodewig

    Stefan Bodewig - 2008-04-04

    Logged In: YES
    user_id=113148
    Originator: NO

    my fault, the &quot; case passes even without the setExpandEntityReferences flag and the &#xD; case fails even with the flag. My best guess is that &#xD; simply doesn't expand to the same thing as \r.

    assertXMLEqual("<root>bla&#13;\nbla</root>", "<root>bla&#xD;\nbla</root>")

    passes as well, with and without explicit entity reference expansion.

    Anyway, I've added the flag now. I'd be grateful if you could test XMLUnit's svn trunk, set the flag and see whether it resolves the issues you see (apart from the \r case).

    http://xmlunit.svn.sourceforge.net/viewvc/xmlunit?view=rev&revision=261

     
  • SourceForge Robot

    Logged In: YES
    user_id=1312539
    Originator: NO

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 14 days (the time period specified by
    the administrator of this Tracker).

     
  • SourceForge Robot

    • status: pending-fixed --> closed-fixed
     

Log in to post a comment.