Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
There's more than one way to do things
 
PerlMonks  

Re: XML Compare and exact differences need to be listed out

by wjw (Hermit)
on Sep 30, 2013 at 06:26 UTC ( #1056285=note: print w/ replies, xml ) Need Help??


in reply to XML Compare and exact differences need to be listed out

There are a number of tools (many non-Perl) that will do this for you. However, to help you, it would help to know:

  • What environment are you in? Linux, Windows, OSX, other...?
  • Why are you only looking at Perl tools?
For this kind of comparison I generally use TkDiff

or

Meld or just plain old diff at the command line(this is on *nix of course).

There are numerous tools for Windows as well. Winmerg being one of the free ones.

If you are looking for exclusively programmatic solutions, then knowing more about your environment is almost mandatory.

A quick google search for "diff tools written in perl" came back with Algorithm::Diff, which contrary to its name seems to do what you are describing."Algorithm::Diff - Compute `intelligent' differences between two files / lists"

Hope something in there is useful...


  • ...the majority is always wrong, and always the last to know about it...
  • ..by my will, and by will alone.. I set my mind in motion


Comment on Re: XML Compare and exact differences need to be listed out
Re^2: XML Compare and exact differences need to be listed out
by srikrishnan (Beadle) on Sep 30, 2013 at 09:03 UTC

    Hi,

    Thanks for your reply

    I am in Windows 7 and Activestate perl 5.10

    I am working in Arbortext Advanced print Publisher (3B2) software for Typesetting, this software supports perl, I want to include a perl script in this software for my requirement

    Thanks a lot

    srikrishnan

      Ok, that is a start. We know ActiveState and Win7.

      From your original post, your requirements are:

      • Output is to be a 3rd file containing the differences between original XML and corrected XML
      • Your changes may be as small as the spelling of a single word.
      What other differences would you want to capture?
      • Will a line by line compare work for you?
      • Do you expect larger changes, such as reordering of lines, replacement of lines/sections of the XML?
      • What do you expect the resultant file to look like? (line_number, orig_line, mod_line, change_txt...
      • I guess that leads to the question, what are you going to do with the output you generate? How will you use it?
      I see from some of your previous postings that you do know some Perl.

      You really do need to provide more info when you ask questions though.

      See How do I post a question effectively?.

      It will help others to help you more effectively. Best of luck ...


      • ...the majority is always wrong, and always the last to know about it...
      • ..by my will, and by will alone.. I set my mind in motion

        Hi

        Thanks for your further mail

        I just want line number, column number and the words

        If I get the above details, I will highlight the exact words in my PDF output through my Typesetting software

        I just want to highlight simple word deletions, insertions and modification details

        Thanks

        srikrishnan

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1056285]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (15)
As of 2014-04-21 16:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (496 votes), past polls