java - Meaningful XML comparison -
i trying achieve meaningful xml comparison. want compare 2 different xml know if 'meaningful' equal.
example xml 1:
<?xml version="1.0" encoding="utf-8"?> <al:moattribute> <al:name>impiid</al:name> <al:value>616731935012345678</al:value> </al:moattribute> <al:moattribute> <al:name>impuid</al:name> <al:value>tel:+16167319350</al:value> </al:moattribute>
xml 2 :
<?xml version="1.0" encoding="utf-8"?> <al:moattribute> <al:name>impuid</al:name> <al:value>tel:+16167319350</al:value> </al:moattribute> <al:moattribute> <al:name>impiid</al:name> <al:value>616731935012345678</al:value> </al:moattribute>
in example both xmls 'meaningful' equal differs in sequence of elements. want compare both of them know if equal.
i tried solution :
best way compare 2 xml documents in java
i tried :
xmlunit.setignorewhitespace(true); diff.identical (...); diff.similar (...);
but if xml's differs in sequence, xml comparison returns false.
any suggestions please ?
any tools @ xml level assume order of elements significant. if know in particular vocabulary, order of elements not significant, need tool works understanding of vocabulary. best bet therefore write normalizing transformation (typically in xslt) removes irrelevant differences documents (for example, sorting elements on suitable key) compare equal when compared using standard xml tools (perhaps after xml canonicalisation).
Comments
Post a Comment