title: Comparing a sequence of elements and replacing on match via XSLT/Xpath
body: <p>I'm trying to do an intersect of sorts between two child elements in the same XML document. </p>
  
  <pre><code>&lt;links&gt;
   &lt;old&gt;
     &lt;xref linkend="zzzzz"&gt;/chapter/subchapter[1]/section[2]/@id&lt;/xref&gt;
     &lt;xref linkend="aaaaa"&gt;/chapter/section[1]/@id&lt;/xref&gt;
   &lt;/old&gt;
   &lt;new&gt;
     &lt;xref linkend="xxxxx"&gt;/chapter/subchapter[1]/section[2]/@id&lt;/xref&gt;
     &lt;xref linkend="sssss"&gt;/chapter/@id&lt;/xref&gt;
   &lt;/new&gt;
  &lt;/links&gt;
  </code></pre>
  
  <p>Whenever there is a match between the string path in new/xref and old/xref, I want to join the two elements and create an output like this:</p>
  
  <pre><code>&lt;matches&gt;
    &lt;match old-linkend='zzzzz' new-linkend='xxxxx'&gt;/chapter/subchapter[1]/section[2]/@id&lt;/match&gt;
  &lt;/matches&gt;
  </code></pre>
  
  <p>This is my first attempt at comparing sequences so I'm a little lost. I am using XSLT 2.0 with Saxon.</p>