command line tool for comparing XML files

Discussion in 'XML' started by Corno, Feb 15, 2004.

  1. Corno

    Corno Guest

    Hi all,

    Does anybody know a command line tool (linux or windows) that can compare 2
    XML files. There's only 1 extra requirement that makes it a bit more
    complicated: the order of attributes or elements within an element is of no
    importance, and so the tool should still report that 2 XML files are equal
    even though the order is different.

    Corno
     
    Corno, Feb 15, 2004
    #1
    1. Advertising

  2. xmldiff

    at:
    http://apps.gotdotnet.com/xmltools/xmldiff/default.aspx


    Cheers,

    Dimitre Novatchev [XML MVP],
    FXSL developer, XML Insider,

    http://fxsl.sourceforge.net/ -- the home of FXSL
    Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html


    "Corno" <corno@%spam%.dds.nl> wrote in message
    news:c0naop$dts$...
    > Hi all,
    >
    > Does anybody know a command line tool (linux or windows) that can compare

    2
    > XML files. There's only 1 extra requirement that makes it a bit more
    > complicated: the order of attributes or elements within an element is of

    no
    > importance, and so the tool should still report that 2 XML files are equal
    > even though the order is different.
    >
    > Corno
    >
    >
     
    Dimitre Novatchev [MVP XML], Feb 15, 2004
    #2
    1. Advertising

  3. Corno

    Corno Guest

    "Dimitre Novatchev [MVP XML]" <> wrote in message
    news:c0ndic$18lbte$-berlin.de...
    > xmldiff
    >
    > at:
    > http://apps.gotdotnet.com/xmltools/xmldiff/default.aspx
    >

    Thanks for the suggestion. I tried it out, it had the feature I requested.
    But unfortunately, it doesn't seem to give a return value if the files are
    different. I need that to automate a build process. Do you know any other
    tool that does this?

    TIA,

    Corno
     
    Corno, Feb 15, 2004
    #3
  4. "Corno" <corno@%spam%.dds.nl> wrote in message
    news:c0o9jg$nud$...
    >
    > "Dimitre Novatchev [MVP XML]" <> wrote in message
    > news:c0ndic$18lbte$-berlin.de...
    > > xmldiff
    > >
    > > at:
    > > http://apps.gotdotnet.com/xmltools/xmldiff/default.aspx
    > >

    > Thanks for the suggestion. I tried it out, it had the feature I requested.
    > But unfortunately, it doesn't seem to give a return value if the files are
    > different. I need that to automate a build process. Do you know any other
    > tool that does this?


    You can very easily modify the source code of the XMLDiff console
    application (in the Samples folder) so that Class1.Main returns an int and
    you will write the necessary "return" statements as you wish.

    This sample app now outputs the strings:

    "Files are identical."

    and

    "Files are different."


    Cheers,

    Dimitre Novatchev [XML MVP],
    FXSL developer, XML Insider,

    http://fxsl.sourceforge.net/ -- the home of FXSL
    Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
     
    Dimitre Novatchev [MVP XML], Feb 15, 2004
    #4
  5. "Corno" <corno@%spam%.dds.nl> wrote in message news:<c0naop$dts$>...
    > Hi all,
    >
    > Does anybody know a command line tool (linux or windows) that can compare 2
    > XML files. There's only 1 extra requirement that makes it a bit more
    > complicated: the order of attributes or elements within an element is of no
    > importance, and so the tool should still report that 2 XML files are equal
    > even though the order is different.
    >
    > Corno


    Is the generic problem of comparing two unordered labeled trees NP-complete?
    I think it had been proven to be NP-complete.
     
    Mikhail Grouchinsky, Feb 17, 2004
    #5
  6. In article <>,
    Mikhail Grouchinsky <> wrote:

    >> Does anybody know a command line tool (linux or windows) that can compare 2
    >> XML files. There's only 1 extra requirement that makes it a bit more
    >> complicated: the order of attributes or elements within an element is of no
    >> importance, and so the tool should still report that 2 XML files are equal
    >> even though the order is different.


    >Is the generic problem of comparing two unordered labeled trees NP-complete?
    >I think it had been proven to be NP-complete.


    Sorting attributes into Unicode order is not NP-complete :)

    -- Richard
    --
    Spam filter: to mail me from a .com/.net site, put my surname in the headers.

    FreeBSD rules!
     
    Richard Tobin, Feb 17, 2004
    #6
  7. Corno

    Corno Guest

    "Mikhail Grouchinsky" <> wrote in message
    news:...
    > "Corno" <corno@%spam%.dds.nl> wrote in message

    news:<c0naop$dts$>...
    > > Hi all,
    > >
    > > Does anybody know a command line tool (linux or windows) that can

    compare 2
    > > XML files. There's only 1 extra requirement that makes it a bit more
    > > complicated: the order of attributes or elements within an element is of

    no
    > > importance, and so the tool should still report that 2 XML files are

    equal
    > > even though the order is different.
    > >
    > > Corno

    >
    > Is the generic problem of comparing two unordered labeled trees

    NP-complete?
    > I think it had been proven to be NP-complete.


    It would seem to me that it's not; you could first write them in (a)
    canonical form and then compare them.

    Corno
     
    Corno, Feb 17, 2004
    #7
  8. > > >
    > > > Does anybody know a command line tool (linux or windows) that can

    > compare 2
    > > > XML files. There's only 1 extra requirement that makes it a bit more
    > > > complicated: the order of attributes or elements within an element is of

    > no
    > > > importance, and so the tool should still report that 2 XML files are

    > equal
    > > > even though the order is different.
    > > >
    > > > Corno

    > >
    > > Is the generic problem of comparing two unordered labeled trees

    > NP-complete?
    > > I think it had been proven to be NP-complete.

    >
    > It would seem to me that it's not; you could first write them in (a)
    > canonical form and then compare them.
    >
    > Corno


    You said order of ELEMENTS doesn't matter too.

    EX:

    <a>
    <c/>
    <b>
    <c/>
    </b>
    <b>
    <d/>
    </b>
    </a>

    and

    <a>
    <b>
    <d/>
    </b>
    <c/>
    <b>
    <c/>
    </b>
    </a>

    are equal (per your first e-mail)

    So simple canonicalization is not going to help you as it doesn't
    change the order of elements.

    In other hand to compare two elements which have children
    but have same name and same set of attributes you will run into same
    tree comparison problem (you have to compare two subtrees of these
    elements).

    Anyway I should have been more clear in my first post

    It has been proven that computing the edit distance for unordered
    labeled trees is NP-complete.

    Zhang, R. Statman, D. Shasha, "On the editing distance between
    unordered labeled trees",

    It seems you are interested only in matching two unordered labeled
    trees.
    (Which is actually making sure that editing distance is zero).

    This task could be easier, but I'm not sure about that.
     
    Mikhail Grouchinsky, Feb 19, 2004
    #8
  9. Corno

    Joe Guest

    Hi, there is a command line tool MDCXML, at http://www.a7soft.com
    Joe Andersen.

    "Corno" <corno@%spam%.dds.nl> wrote in message news:<c0naop$dts$>...
    > Hi all,
    >
    > Does anybody know a command line tool (linux or windows) that can compare 2
    > XML files. There's only 1 extra requirement that makes it a bit more
    > complicated: the order of attributes or elements within an element is of no
    > importance, and so the tool should still report that 2 XML files are equal
    > even though the order is different.
    >
    > Corno
     
    Joe, Feb 22, 2004
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joe
    Replies:
    0
    Views:
    423
  2. Bernd Oninger
    Replies:
    1
    Views:
    839
    Martin Honnen
    Jul 7, 2004
  3. Dave
    Replies:
    9
    Views:
    16,842
    RichardShepherd
    Jan 1, 2012
  4. Dave
    Replies:
    7
    Views:
    569
    Phlip
    Aug 10, 2004
  5. Frost
    Replies:
    8
    Views:
    545
    Vladimir S. Oka
    Feb 10, 2006
Loading...

Share This Page