checking for absent elements

  • Lou

    Lou - 2008-11-20

    Can someone explain what is the proper way to check for absent elements.  Given the following snippet:

    Difference diff = (Difference);
    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:



    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?


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks