I was using the values returned from the getValue() calls to check for the string "null" and then classify the change as insert, update or delete. For example, if the control/src value is null, but the test value is not, then it must be an add.
So, given the following XML fragment:
CONTROL
<dummyroot/>
TEST
<dummyroot>
<order_conditions>
<condition_code>ABC</condition_code>
</order_conditions>
</dummyroot>
I'm getting the following results:
control value returned: false
test value returned: true
I could swear this was returning the string "null" - could it be related to the qualifier I am using? What should I expect from these calls when the nodes are absent?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Can someone explain what is the proper way to check for absent elements. Given the following snippet:
Difference diff = (Difference)iter.next();
NodeDetail ndSrc = diff.getControlNodeDetail();
NodeDetail ndTst = diff.getTestNodeDetail();
String sname = "?";
String srcVal = "?";
String dname = "?";
String tstVal = "?";
String ndSrcVal = ndSrc.getValue();
String ndTstVal = ndTst.getValue();
I was using the values returned from the getValue() calls to check for the string "null" and then classify the change as insert, update or delete. For example, if the control/src value is null, but the test value is not, then it must be an add.
So, given the following XML fragment:
CONTROL
<dummyroot/>
TEST
<dummyroot>
<order_conditions>
<condition_code>ABC</condition_code>
</order_conditions>
</dummyroot>
I'm getting the following results:
control value returned: false
test value returned: true
I could swear this was returning the string "null" - could it be related to the qualifier I am using? What should I expect from these calls when the nodes are absent?
the first difference you get will be about different numbers of children and both will point at /dummyroot.
Uhm no, the first difference probably is HAS_CHILD_NODES and explains the false/true values.
See the tables in
http://xmlunit.sourceforge.net/userguide/html/ar01s03.html#The%20Difference%20Engine