# # # compare_nodes.cfv # # # # # # subroutine(compare_nodes( node a_ori, node b_ori), ( debug_message("#### compare_nodes() \n"); # This subroutine compares two nodes and its values and displays any differences in a HTML table. # The order of the subnodes is not relevant. Nodes which are sorted differently but have # the same subnodes and values will show that the two nodes are equal. # # # # compare_a_against_b() # # # subroutine(compare_a_against_b( node a, node b, node c), ( node item; string item_value; string item_path; string parent_path; foreach item a ( if (num_subnodes(item) > 0) then ( compare_a_against_b(item, b, c); ) else ( item_value = @item; item_path = replace_first(item, "v.__a__.", ""); # debug_message("#### item_path in a: " . item_path . "\n"); if (!?(b . "." . item_path)) then ( # Track that the node only exists in a # debug_message("#### TRACK NODE IN C\n\n"); c . "." . item_path . ".__node_exists_in_a__" = true; c . "." . item_path . ".__node_exists_in_b__" = false; c . "." . item_path . ".__a_item_value__" = item_value; c . "." . item_path . ".__b_item_value__" = ""; ) else ( # debug_message("#### NODE EXISTS IN C \n"); if (@("v.__b__." . item_path) ne item_value) then ( # Track that the node has different values c . "." . item_path . ".__node_exists_in_a__" = true; c . "." . item_path . ".__node_exists_in_b__" = true; c . "." . item_path . ".__a_item_value__" = item_value; c . "." . item_path . ".__b_item_value__" = @("v.__b__." . item_path); ); ); ); ); )); # # # # compare_b_against_a() # # # subroutine(compare_b_against_a( node a, node b, node c), ( node item; string item_name; string item_path; foreach item b ( # debug_message("#### item: " . item . "\n"); # debug_message("#### num_subnodes(item): " . num_subnodes(item) . "\n"); if (num_subnodes(item) > 0) then ( compare_b_against_a(a, item, c); ) else ( item_path = replace_first(item, "v.__b__.", ""); # debug_message("#### item_path of item in b: " . item_path . "\n"); # If this subnode does not exist in a then add it to c, # else it has already been covered in compare_a_against_b if (!?(a . "." . item_path)) then ( c . "." . item_path . ".__node_exists_in_a__" = false; c . "." . item_path . ".__node_exists_in_b__" = true; c . "." . item_path . ".__a_item_value__" = ""; c . "." . item_path . ".__b_item_value__" = @item; ); ); ); )); # # # # create_node_differences_html() # # # subroutine(create_node_differences_html( node c), ( node item; string item_name; string item_value; string item_path; foreach item c ( if (item?{"__node_exists_in_a__"} and item?{"__node_exists_in_b__"}) then ( item_path = replace_first(item, "v.__c__.", ""); # Show the item '
' . a_ori . ' | '; ''; ' | '; ' | ' . b_ori . ' | '; ''; ' | '; ' |
---|