I have a file that has the following xml
<?xml version="1.0"?>
<request>
<order_query ordernumber="3065"/>
<order_query ordernumber="3066"/>
</request>
There are end of line and tab characters in the above file.
I have an xml string as follows:
<?xml version="1.0"?>
<request><order_query ordernumber="3065"/><order_query ordernumber="3066"/></request>
There is one end of line character in the above xml.
My code is as follows:
XMLUnit.setIgnoreWhitespace(true);
assertXMLEqual("Query XML Not Similar For Collection", xmlFileReader, new StringReader(testQueryXml));
// xmlFileReader is a FileReader for the above mentioned file.
// testQueryXml is a string that has the above xml contained in a string.
The error I get is
[different] Expected number of child nodes '5' but was '2' - comparing <request...> to <request...>
My understanding is that if I set the XMLUnit.setIgnoreWhitespace(true), then all form feeds, tabs, etc.. are read as empty elements and ignored.
Is this incorrect or is this a bug in XMLUnit?
Thanx
Bhaskar
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Your understanding is correct - the whole point of setIgnoreWhitespace(true) is to remove these redundant text nodes. Indeed the JUnit tests prove that it works OK with Xalan/Xerces as the underlying XML tools - look at or better try to run test_Diff.testXMLUnitDoesNotWorkWellWithFiles() and see what happens.
Rgds,
Tim
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have a file that has the following xml
<?xml version="1.0"?>
<request>
<order_query ordernumber="3065"/>
<order_query ordernumber="3066"/>
</request>
There are end of line and tab characters in the above file.
I have an xml string as follows:
<?xml version="1.0"?>
<request><order_query ordernumber="3065"/><order_query ordernumber="3066"/></request>
There is one end of line character in the above xml.
My code is as follows:
XMLUnit.setIgnoreWhitespace(true);
assertXMLEqual("Query XML Not Similar For Collection", xmlFileReader, new StringReader(testQueryXml));
// xmlFileReader is a FileReader for the above mentioned file.
// testQueryXml is a string that has the above xml contained in a string.
The error I get is
[different] Expected number of child nodes '5' but was '2' - comparing <request...> to <request...>
My understanding is that if I set the XMLUnit.setIgnoreWhitespace(true), then all form feeds, tabs, etc.. are read as empty elements and ignored.
Is this incorrect or is this a bug in XMLUnit?
Thanx
Bhaskar
Your understanding is correct - the whole point of setIgnoreWhitespace(true) is to remove these redundant text nodes. Indeed the JUnit tests prove that it works OK with Xalan/Xerces as the underlying XML tools - look at or better try to run test_Diff.testXMLUnitDoesNotWorkWellWithFiles() and see what happens.
Rgds,
Tim