0 Replies Latest reply: Dec 12, 2013 10:11 AM by knp RSS

    XMLUnit: Element and Attribute ordering problem

    knp

      My question is similar to:

      XMLUnit: Element and Attribute ordering problem

       

      Let's say my original xml is:

       

      <top>

            <child 1>  </child 1>

            <child 2>

                        <sub child 21>  </sub child 21>

                        <sub child 22>  <sub child 22>

            </child 2>

            <child 3>

                       <sub child 31>  </sub child 31>

                       <sub child 32>  </sub child 32>

                       <sub child 33>  </sub child 33>

            </child 3>

            <child 4>  </child 4>

            <child 5>  </child 5>

      </top>

                      

       

      I modified the xml to be tested, by moving the child 3 section into child 2:

       

      <top>

            <child 1>  </child 1>

            <child 2>

                        <sub child 21>  </sub child 21>

                        <sub child 22>  <sub child 22>

                        <child 3>

                                    <sub child 31>  </sub child 31>

                                    <sub child 32>  </sub child 32>

                                    <sub child 33>  </sub child 33>

                       </child 3>

            </child 2>

            <child 4>  </child 4>

            <child 5>  </child 5>

      </top>

       

      When I run XMLUnit Detailed Diff, the output is:

       

      Similar? false

      Identical? false

      ***********************

      Expected number of child nodes '5' but was '4' - comparing <top..> at .........

      ***********************

      ***********************

      Expected number of child nodes '2' but was '3' - comparing <child 2...> at ...

      ***********************

      ***********************

      Expected presence of child node 'null' but was 'child 3' - comparing  at null to <child 3...> at .....

      ***********************

      ***********************

      Expected presence of child node 'child 3' but was 'null' - comparing <child 3...> at ......

      ***********************

      ***********************

      Expected sequence of child nodes '4' but was '3' - comparing <child 4...> at ....

      ***********************

      ***********************

      Expected sequence of child nodes '5' but was '4' - comparing <child 5...> at ....

      ***********************

       

      My code uses:

          XMLUnit.setIgnoreAttributeOrder(true);

          XMLUnit.setIgnoreComments(true);

          XMLUnit.setIgnoreWhitespace(true);

          XMLUnit.setNormalizeWhitespace(Boolean.TRUE); 

       

          Diff diff = new Diff(fr1, fr2);

          diff.overrideElementQualifier(new ElementNameAndAttributeQualifier());

          DetailedDiff detDiff = new DetailedDiff(diff);

       

      My question is:

      Just because I changed the position of child 3 from being top->child 3   to    top>child 2->child 3, I get so many difference messages for the nodes below the problem node. I understand that they are differences too as they have shifted to top because I removed child 3. But is there a way to not show the extra messages for the nodes below the problem node?

       

      Please advise.