i'd like compare two xml files with these following features
// control.xml
<ela id="user-content-01">
<..>...</..>
</ela>
<elb id="user-content-02">
<..>...</..>
</elb>
<elc elaref="01" elbref="02">
<..>...</..>
</elc>
// test.xml
<ela id="user-content-05">
<..>...</..>
</ela>
<elb id="user-content-06">
<..>...</..>
</elb>
<elc elaref="05" elbref="06">
<..>...</..>
</elc>
The element <elc> have two reference to elements <ela> and <elb>. Doesn't matter that id's attributes are identical so i've created my custom DifferenceListener that ignore difference about different id, elaRef and elbRef.</elb></ela></elc>
The problem is that i'd like compare two content's elements <elc> and its content's reference ignoring
id value attribute.</elc>
I've seen the function XMLUnit.setExpandEntityReferences(Boolean.TRUE); could help me, but i'm not sure to had understood the real behavior of it.
Can you help me?
Last edit: Fabio Nepi 2015-03-23
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Entity References are the sequences in XML that start with & and end with ; so it is not related to your case. This looks more like https://github.com/xmlunit/xmlunit/issues/3 - if you've got a schema that identifies the attributes as IDs or IDREFs. So far nobody has worked on the issue.
I'm not completely sure I understand your usecase, if you want to ignore the value of certain attributes than your custom DifferenceListener is the best approach you can take. You could have used TextDifferenceListenerBase from the examples package to reduce some boilerplate code, but not by much.
I would have expected that you needed to ensure the elc-elements actually pointed to the same (or at least existing) elements, that would be a lot harder to do.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
i'd like compare two xml files with these following features
// control.xml
<ela id="user-content-01">
<..>...</..>
</ela>
<elb id="user-content-02">
<..>...</..>
</elb>
<elc elaref="01" elbref="02">
<..>...</..>
</elc>
// test.xml
<ela id="user-content-05">
<..>...</..>
</ela>
<elb id="user-content-06">
<..>...</..>
</elb>
<elc elaref="05" elbref="06">
<..>...</..>
</elc>
The element <elc> have two reference to elements <ela> and <elb>. Doesn't matter that id's attributes are identical so i've created my custom DifferenceListener that ignore difference about different id, elaRef and elbRef.</elb></ela></elc>
The problem is that i'd like compare two content's elements <elc> and its content's reference ignoring
id value attribute.</elc>
I've seen the function XMLUnit.setExpandEntityReferences(Boolean.TRUE); could help me, but i'm not sure to had understood the real behavior of it.
Can you help me?
Last edit: Fabio Nepi 2015-03-23
I've solved it editing my DifferenceListener in this way:
1) I've declared following variables for my class that implements DifferenceListener:
2) I've editing my method isIgnoredDifference(Difference difference) returning a boolean:
}
but I'd like know if exists a more efficient method to get it.
Thanks.
Fabio
Last edit: Fabio Nepi 2015-03-23
Hi Fabio
Entity References are the sequences in XML that start with & and end with ; so it is not related to your case. This looks more like https://github.com/xmlunit/xmlunit/issues/3 - if you've got a schema that identifies the attributes as IDs or IDREFs. So far nobody has worked on the issue.
I'm not completely sure I understand your usecase, if you want to ignore the value of certain attributes than your custom DifferenceListener is the best approach you can take. You could have used
TextDifferenceListenerBasefrom the examples package to reduce some boilerplate code, but not by much.I would have expected that you needed to ensure the elc-elements actually pointed to the same (or at least existing) elements, that would be a lot harder to do.