I have 2 XML. I have been using XMLUnit for comparing the 2 xml strings. The problem is I am not able to ignore the order in which elements occur. I tried overriding ElementQualifier as well as DifferenceListener but that didn't help for this scenario.
Control XML
<xs:complexType>
<xs:anotation>
<xs:description>
<Description>Country</Description>
</xs:description>
</xs:anotation>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="address" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="country" type="xs:string"/>
</xs:sequence>
</xs:complexType>
Test XML
<xs:complexType>
<xs:anotation>
<xs:description>
<Description>Country</Description>
</xs:description>
</xs:anotation>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="address" type="xs:string"/>
</xs:sequence>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="address" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="street" type="xs:string"/>
</xs:sequence>
</xs:complexType>
Note that in Test XML another sequence is added and last element(country) of 1st sequence is removed.
XMLUnit complains about not having the element named city
which is there in second sequence. Its taking the elements in Order. I tried Overriding ELementNameAndAttributeQualifier but didnt produced the desired result.Moreover, overriding RecursiveElemenNameAndTextQualifier didnt help either. The reason RecursiveElemenNameAndTextQualifier doesn't work because theres is no match for the 1st sequence. How would I approach and make sure
public boolean qualifyForComparison(Element element, Element element1)
{
// should return true only when **element 1** has all elements of **element**
}