#1 2008-03-05 16:49:52

pegaz
Member
Registered: 2008-03-05
Posts: 34

Comparing 2 XML files

Tags: [comparison, java, xml]

hi everyone,
i'm trying to compare two XML files that have the same structure. My question is: How can i do to show the difference between the two XML files. Any solutions?
Best regards.

Pegaz

Offline

#2 2008-03-05 16:52:56

cahsohtoa
Member
Company: AEFE
Registered: 2008-02-19
Posts: 261
Website

Re: Comparing 2 XML files

Are your data sorted?

Offline

#3 2008-03-05 17:00:38

cahsohtoa
Member
Company: AEFE
Registered: 2008-02-19
Posts: 261
Website

Re: Comparing 2 XML files

Are your differents data in the same file or they might be in both file?

Offline

#4 2008-03-05 17:11:17

pegaz
Member
Registered: 2008-03-05
Posts: 34

Re: Comparing 2 XML files

my data are sorted, and i have 2 XML files having the same structure.

Offline

#5 2008-03-05 17:36:24

cahsohtoa
Member
Company: AEFE
Registered: 2008-02-19
Posts: 261
Website

Re: Comparing 2 XML files

I didn't find yet the solution to know the differences between the two file but I've found a solution to know the similar data.
Are you interested?

Offline

#6 2008-03-05 17:52:23

pegaz
Member
Registered: 2008-03-05
Posts: 34

Re: Comparing 2 XML files

For sure! thank's

Offline

#7 2008-03-05 17:59:43

cahsohtoa
Member
Company: AEFE
Registered: 2008-02-19
Posts: 261
Website

Re: Comparing 2 XML files

I did this example with two CSV file, with the same structure but with some differents values.

I've used a tUnite and after a tUniqRow.

I've used all the field as Key attribute in the tUniqRow.

As output use the Duplicates flow to see all the similar values.

However if file1 and file2 have a same row= [a,a] you will see this row two times.

So I added a tAggregateRow and the groupby function in it for each field


Uploaded Images

Last edited by cahsohtoa (2008-03-05 18:00:52)

Offline

#8 2008-03-05 18:15:03

pegaz
Member
Registered: 2008-03-05
Posts: 34

Re: Comparing 2 XML files

i'm trying ur example...

Offline

#9 2008-03-07 11:01:53

pegaz
Member
Registered: 2008-03-05
Posts: 34

Re: Comparing 2 XML files

i tried to realise a job concerning the comparaison of the 2 XML files.
Here is a screenshot of my job:
http://aminebenzakour.free.fr/talend/schema.GIF
and here is the variables regarding the tFileCompare_1 settings:
http://aminebenzakour.free.fr/talend/tFileCompare_1.GIF
Can you help me to resolve my problem, this is the error message:
http://aminebenzakour.free.fr/talend/erreur.GIF

Regards,
Pegaz

Last edited by pegaz (2008-03-07 11:09:04)

Offline

#10 2008-03-07 11:12:27

cantoine
Talend team
Registered: 2006-09-19
Posts: 715
Website

Re: Comparing 2 XML files

Hi,

Why do you have specific characters in "If no differences detected, display" field.

Your error is a CodeGenerator mistake due to a bad character in your component properties.

Regards,

Offline

#11 2008-03-07 11:21:34

pegaz
Member
Registered: 2008-03-05
Posts: 34

Re: Comparing 2 XML files

Doesn't change anything when i delete specific characters sad

Offline

#12 2008-03-07 11:30:32

cantoine
Talend team
Registered: 2006-09-19
Posts: 715
Website

Re: Comparing 2 XML files

Hi,

If you switch your designer tab to code tab, you will see the line in the codeGenerator with the compilation error.
Can you send a screenshot or a copy/paste of this area, please.

Regards;

Offline

#13 2008-03-07 11:33:34

cahsohtoa
Member
Company: AEFE
Registered: 2008-02-19
Posts: 261
Website

Re: Comparing 2 XML files

you can try with two tfile list.
In each tFilelist you specified the directory and the name file
After you can use ((String)globalMap.get("tFileList_1_CURRENT_FILEPATH")) & ((String)globalMap.get("tFileList_2_CURRENT_FILEPATH"))


Uploaded Images

Offline

#14 2008-03-07 11:47:14

cantoine
Talend team
Registered: 2006-09-19
Posts: 715
Website

Re: Comparing 2 XML files

Hi,

In your case, you need Iterate only on one Folder to compare with one reference file.

Can you try this, remove tFileList2 component ?

You can find further information in our User Guide.

Regards;

Offline

#15 2008-03-07 12:17:12

pegaz
Member
Registered: 2008-03-05
Posts: 34

Re: Comparing 2 XML files

my tfilecompare_1 output contains the default parameters(file, file_ref,moment,...) . I can't change it !
is it possible to change the output?

Offline

#16 2008-03-07 12:20:26

cahsohtoa
Member
Company: AEFE
Registered: 2008-02-19
Posts: 261
Website

Re: Comparing 2 XML files

what do you want in your output?

Last edited by cahsohtoa (2008-03-07 12:20:43)

Offline

#17 2008-03-07 12:22:36

pegaz
Member
Registered: 2008-03-05
Posts: 34

Re: Comparing 2 XML files

i want to show as an output my own columns related to my project

Offline

#18 2008-03-07 12:24:40

cahsohtoa
Member
Company: AEFE
Registered: 2008-02-19
Posts: 261
Website

Re: Comparing 2 XML files

your own columns? What do you mean? You want to choose only some few columns from the tFileCompare or the row of each file?

Offline

#19 2008-03-07 12:31:50

pegaz
Member
Registered: 2008-03-05
Posts: 34

Re: Comparing 2 XML files

yes, only some few columns from the tFileCompare

Offline

#20 2008-03-07 12:34:31

cahsohtoa
Member
Company: AEFE
Registered: 2008-02-19
Posts: 261
Website

Re: Comparing 2 XML files

you can use a tMap smile

Offline

#21 2008-03-13 10:16:46

pegaz
Member
Registered: 2008-03-05
Posts: 34

Re: Comparing 2 XML files

hello,

I need to compare 2 XML files. Actually, I can do this, show if the files differ or not and how many lines do they differ.
My question is: How can i identify which row do they differ and what is the id. Let's consider this example:

xml1:                                                   xml2:
id= 12                                                  id= 12
first_name= MACKLEY                           first_name= MACKLEY
last_name= bob                                    last_name= david


I want to see as a result: the 2 XML files differ/ they differ on: last_name / the id= 12

Regards.

Pegaz

Offline

#22 2008-03-13 11:57:50

cahsohtoa
Member
Company: AEFE
Registered: 2008-02-19
Posts: 261
Website

Re: Comparing 2 XML files

I'm thinking that it would be a really good idea to developp a new component that permits to compare two files row by row.
Please wait for a talend team opinion but I think it will be an option to put it into the buggtracker

Offline

#23 2008-03-13 15:33:28

pegaz
Member
Registered: 2008-03-05
Posts: 34

Re: Comparing 2 XML files

i'm trying to switch to an other solution using tmap.

tFileInputXML_1--------->
                                              tMap_1---------->  tLogRow_1
tFileInputXML_2--------->

any suggestions?

thank's

Offline

#24 2008-03-13 16:20:19

cahsohtoa
Member
Company: AEFE
Registered: 2008-02-19
Posts: 261
Website

Re: Comparing 2 XML files

do you have many fields to compare?

Last edited by cahsohtoa (2008-03-13 16:20:41)

Offline

#25 2008-03-13 16:23:59

pegaz
Member
Registered: 2008-03-05
Posts: 34

Re: Comparing 2 XML files

no, only 2 fields at this moment.

Offline

Board footer

Powered by FluxBB