Menu

What is child nodelist length and child nodelist sequence?

Help
Hari Rao
2018-01-05
2018-01-10
  • Hari Rao

    Hari Rao - 2018-01-05

    Hi,

    I am using 2.5.1 XML Unit. When I compare two XMLs' I get the following

    Expected child nodelist length '13' but was '15'

    Expected child nodelist sequence '2' but was '1'

    When I count the no of child nodes in both the XMLs' I do not see any difference. So what does this mean?
    What does nodelist sequence mean?

    Please help.

     
  • Stefan Bodewig

    Stefan Bodewig - 2018-01-05

    Unless you tell XMLUnit to ignore whitespace "element content whitespace" like linebreaks between elements or spaces used for indentation may cause a different number of children.

    When looking up differences I'd recommend you go by the type of comparison rather than the text. "child nodelist sequence" is the CHILD_NODELIST_SEQUENCE comparison which is used to compare the order of nodes. In your case it says whatever is the second child in your control node has been matched to the first child in the test node so the order is different.

    Judging from the two messages I'd guess there is an empty whitespace-only text node right after the opening element tag in your control document that is not present in the test document.

     
  • Hari Rao

    Hari Rao - 2018-01-05

    thanks for the info.

    I understand that there are two types of ignore white spaces (setIgnoreWhitespace and setNormalizeWhitespace ). I will go with setIgnoreWhitespace (referred - http://xmlunit.sourceforge.net/userguide/html/ar01s03.html#Comparing:%20Configuration)

    I am using DifferenceEngine differenceEngine = new DOMDifferenceEngine(); to compare so how do I configure XMLunit to ignore the whitepace. I dont see this method in DifferenceEngine. Sorry I am new so I am asking low level details as well.

     
  • Hari Rao

    Hari Rao - 2018-01-05

    also is there a way to disable checking the nodelist sequece?

     
  • Hari Rao

    Hari Rao - 2018-01-10

    thank you very much. If I downgrade difference to equal the the text differences r not highlighted. i read the DifferenceEvaluator user guide. It says diferent order of child nodes are considered similar. this is what i want so i will leave it as default. now i am facing a problem where in it thinks 42 and 42.00000 are different, 0.5 and 0.500 are differernt. is there anything available in Xmlunit to overcome this ?

     
  • Hari Rao

    Hari Rao - 2018-01-10

    I will open another conversation for this topic. thanks a lot for all your inputs.

     

Log in to post a comment.