このコード:
import org.custommonkey.xmlunit.Diff;
String result = "<ns1:Square xsi:type=\"ns1:Shape\" xmlns:ns1=\"http://example.com/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>";
String correct = "<ns2:Square xsi:type=\"ns2:Shape\" xmlns:ns2=\"http://example.com/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>";
Diff diff = new Diff(result, correct);
System.out.println("diff:" + diff);
System.out.println("diff.similar(): " + diff.similar());
結果:
diff: org.custommonkey.xmlunit.Diff
[not identical] Expected namespace prefix 'ns1' but was 'ns2' - comparing <ns1:Square...> at /Square[1] to <ns2:Square...> at /Square[1]
[different] Expected attribute value 'ns1:Shape' but was 'ns2:Shape' - comparing <ns1:Square xsi:type="ns1:Shape"...> at /Square[1]/@type to <ns2:Square xsi:type="ns2:Shape"...> at /Square[1]/@type
diff.similar(): false
diff.similar()がtrueであると期待します。またはそれが間違っている理由はありますか?それともバグですか?
xsi:type infoを削除すると、trueが返されます。
それを修正する方法はありますか?