When this option is enabled XML::SemanticDiff will add the startline and endline properties (containing the line numbers for the reported elements start tag and end tag) to each warning. For attribute events these numbers reflect the start and end tags of the element which contains that attribute.
When this option is enabled XML::SemanticDiff will add the old_value and new_value properties to each warning. These properties contain, surprisingly, the old and new values for the element or attribute being reported.
In the case of missing elements or attributes (those in the first document, not in the second) only the old_value property will be defined. Similarly, in the case of rogue elements or attributes (those in the second document but not in the first) only the new_value property will be defined.
Note that using this option will greatly increase the amount of memory used by your application.
Taking a blessed object as its sole argument, this option provides a way to hook the basic semantic diff engine into your own custom handler class.
Please see the section on CUSTOM HANDLERS below.
This option takes array of strings as argument. Strings are interpreted as simple xpath expressions. Nodes matching these expressions are ignored during comparison. All xpath expressions should be absolute (start with /).
Current implementation ignores namespaces during comparison.
This will be considered if it is a string that does not contain newlines and exists in the filesystem.
the XML text itself.
This will be considered if its any kind of string.
the results of read_xml(). (see below)
This will be considered if its a hash reference.
Internally, XML::SemanticDiff uses an event-based model somewhat reminiscent of SAX where the various semantic diff events are handed off to a separate handler class to cope with the details. For most general cases where the user only cares about reporting the differences between two docs, the default handler, XML::SemanticDiff::BasicHandler, will probably suffice. However, it is often desirable to add side-effects to the diff process (updating datastores, widget callbacks, etc.) and a custom handler allows you to be creative with what to do about differences between two XML documents and how those differences are reported back to the application through the compare() method.
The following is a list of handler methods that can be used for your custom diff-handler class.
init($self, CW$diff_obj)The init method is called immediately before the the two document HASHes are compared. The blessed XML::SemanticDiff object is passed as the sole argument, so any values that you wish to pass from your application to your custom handler can safely be added to the call to XML::SemanticDiffs constructor method.
rogue_element($self, CW$element_name, CW$todoc_element_properties)The rogue_element method handles those cases where a given element exists in the to-file but not in the from-file.
missing_element($self, CW$element_name, CW$fromdoc_element_properties)The missing_element method handles those cases where a given element exists in the from-file but not in the to-file.
element_value($self, CW$element, CW$to_element_properties, CW$fromdoc_element_properties)The element_value method handles those cases where the text data differs between two elements that have the same name, namespace URI, and are at the same location in the document tree. Note that all whitespace is normalized and the text from mixed-content elements (those containing both text and child elements mixed together) is aggregated down to a single value.
namespace_uri($self, CW$element, CW$todoc_element_properties, CW$fromdoc_element_properties)The namespace_uri method handles case where the XML namespace URI differs between a given element in the two documents. Note that the namespace URI is checked, not the element prefixes since <foo:element/> <bar:element/> and <element/> are all considered equivalent as long as they are bound to the same namespace URI.
rogue_attribute($self, CW$attr_name, CW$element, CW$todoc_element_properties)The rogue_attribute method handles those cases where an attribute exists in a given element the to-file but not in the from-file.
missing_attribute($self, CW$attr_name, CW$element, CW$todoc_element_properties, CW$fromdoc_element_properties)The missing_attribute method handles those cases where an attribute exists in a given element exists in the from-file but not in the to-file.
attribute_value($self, CW$attr_name, CW$element, CW$todoc_element_properties, CW$fromdoc_element_properties)The attribute_value method handles those cases where the value of an attribute varies between the same element in both documents.
final($self, CW$diff_obj)The final method is called immediately after the two document HASHes are compared. Like the init handler, it is passed a copy of the XML::SemanticDiff object as its sole argument.
Note that if a given method is not implemented in your custom handler class, XML::SemanticDiff will not complain; but it means that all of those events will be silently ignored. Consider yourself warned.
Originally by Kip Hampton, firstname.lastname@example.org .
Further Maintained by Shlomi Fish, <http://www.shlomifish.org/> .
Copyright (c) 2000 Kip Hampton. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Shlomi Fish hereby disclaims any implicit or explicit copyrights on this software.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
|perl v5.20.3||XML::SEMANTICDIFF (3)||2016-03-17|