title: XSLT - Compare two similarXML files
body: <p>I have two XML-files similar to this:</p>
  
  <p>1.</p>
  
  <pre><code>&lt;data&gt;
     &lt;object ID="1"&gt;
        &lt;ID&gt;1&lt;/ID&gt;
        &lt;name&gt;abc&lt;/name&gt;
        &lt;weight&gt;50&lt;/weight&gt;
     &lt;/object&gt;
     &lt;object ID="2"&gt;
        &lt;ID&gt;2&lt;/ID&gt;
        &lt;name&gt;def&lt;/name&gt;
        &lt;weight&gt;75&lt;/weight&gt;
     &lt;/object&gt;
  &lt;/data&gt;
  </code></pre>
  
  <p>2.</p>
  
  <pre><code>&lt;data&gt;
     &lt;object ID="2"&gt;
        &lt;ID&gt;2&lt;/ID&gt;
        &lt;name&gt;def&lt;/name&gt;
        &lt;weight&gt;75&lt;/weight&gt;
     &lt;/object&gt;
     &lt;object ID="3"&gt;
        &lt;ID&gt;3&lt;/ID&gt;
        &lt;name&gt;ghi&lt;/name&gt;
        &lt;weight&gt;100&lt;/weight&gt;
     &lt;/object&gt;
  &lt;/data&gt;
  </code></pre>
  
  <p>And now I want to compare them. Either with an additional element (something like both) or a new files (in_both_files.xml, only_in_file1.xml, only_in_file2.xml). I know, XSLT is not the best for this quest, i am missing PHP/SQL... 
  What would be the best way to solve this problem?
  I already searched for a solution, but most people seem to be happy to just merge it. 
  My idea was to give every object the ID as attribut and then go through the first file and use document() and key() to look for the same object in the other file. Is this good/even possible? Didn't work by now, and i don't know, whether it's the right way. </p>
  
  <p>Edit:
  This is for a stocktaking. One XML-file is the objects we have, according to the system and the other one what is really in the depot. So if one object appears on both lists, they have the absolute same ID, name, weight, etc. But the ID is the only thing, thats absolute uniquefor each object (but of course should be in both files). So I need to know, which object are in the depot but not in the system, so I can import them, and which ones are in the system, but not in the depot, and so have to be labeld as "lost".</p>
  
  <p>So just merging them, won't help...</p>
  
  <p>A result like</p>
  
  <pre><code>only_in_system.xml
  &lt;data&gt;
     &lt;object&gt;
        &lt;ID&gt;1&lt;/ID&gt;
        &lt;name&gt;abc&lt;/name&gt;
        &lt;weight&gt;50&lt;/weight&gt;
     &lt;/object&gt;
  &lt;/data&gt;
  
  only_in_depot.xml
  &lt;data&gt;
     &lt;object&gt;
        &lt;ID&gt;3&lt;/ID&gt;
        &lt;name&gt;ghi&lt;/name&gt;
        &lt;weight&gt;100&lt;/weight&gt;
     &lt;/object&gt;
  &lt;/data&gt;
  
  (additional) everything_is_ok.xml
  &lt;data&gt;
     &lt;object&gt;
        &lt;ID&gt;2&lt;/ID&gt;
        &lt;name&gt;def&lt;/name&gt;
        &lt;weight&gt;75&lt;/weight&gt;
     &lt;/object&gt;
  &lt;/data&gt;
  </code></pre>
  
  <p>would be nice! Also more individual transormations could be used (and i think, have to) in a row!</p>