woland99 has asked for the wisdom of the Perl Monks concerning the following question:

This is more of XML'y rather than Perl'y question but perhaps it is common knowledge here...
Assume that I have XML file that describes physical configuration - for the sake of argument letsay it is about
Item (that has TYPE and some internal ID) Container (that has TYPE and some internal ID)
So XML file describes collection of items sitting in containers.
So now I have two files - each one describes some collection of items of some TYPE sitting in container of certain TYPE.

How can I verify that those two files describe same physical configuration?

Is it a common XML problem and there is some module somewhere that can be helpful in developing script to compare two configuration?
TIA for any pointers, keywords etc...
PS. My real life problem deals with configuration that has much more depth than mere items and containers.
PS2."internal ID" has no relevance outside of given file - but inside the file it may be used to describe to refer to element as part of some construct (eg some other relation beyond containment).

Replies are listed 'Best First'.
Re: comparing XML files
by toolic (Bishop) on Dec 14, 2011 at 16:42 UTC
      Thanks for the pointer - I will check Semantic::Diff
Re: comparing XML files
by choroba (Cardinal) on Dec 14, 2011 at 16:47 UTC
    What do you mean by the "same physical configuration"? Can you give an XML example?
    When I need to compare two XML files, I usually standardize them somehow (xmllint --c14n | xmllint --format) and then run a normal diff. You might need to replace the IDs on the standardized files.
      Actual data sample would not do a lot of good - the XML files I work with describe connection and placement of parts so are not too readable (way too complex). I think that Items/Containers example describes basic question well.
      To make it slightly more complex lets assume that when an Item is ordered it has color so described by element Item_Color is created and when subsequently that item is placed in a Container it gets a reference to Item_Placement element that has reference pointing to that Container.
      <?xml version="1.0" encoding="UTF-8"?> <Configuration> <Description>Items in Containers</Description> <Item_Color id="1" color="Blue"> <Reference refType="Placement Data" id="2"></Reference> </Item_Color> <Item_Placement id="2"> <Reference refType="Physical Placement" id="3"></Reference> </Item_Placement> <Container id="3" color="White"></Container> <Item_Color id="4" color="Red"> <Reference refType="Placement Data" id="6"></Reference> </Item_Color> <Item_Placement id="6"> <Reference refType="Physical Placement" id="3"></Reference> </Item_Placement> </Configuration>
      So that means Blue and Red items sit in White container.
      The same configuration can be described by a file that has different set of IDs - how do I decide it is stil "Blue and Red in White"?
      Is there away to identify that some configuration contains some other as a subset - ie. in some more complex situation we still have "Red and Blue in White" (as part of bigger situation).
Re: comparing XML files
by TJPride (Pilgrim) on Dec 14, 2011 at 17:09 UTC
    How about you supply some samples of your actual data, rather than just giving us clues? It makes it much easier to suggest a solution.