title: Testing for matching file names in Schematron
body: <p>I have an XML document with a list of xml, pdf, and tif files. I need to test via Schematron that each xml has a matching pdf file, and vice versa.</p>
  
  <p>My XML:</p>
  
  <pre><code>&lt;folder&gt;
      &lt;files&gt;
          &lt;file&gt;foo.xml&lt;/file&gt;
          &lt;file&gt;foo.pdf&lt;/file&gt;
          &lt;file&gt;bar.xml&lt;/file&gt;
          &lt;!-- Missing file &lt;file&gt;bar.pdf&lt;/file&gt; --&gt;
          &lt;file&gt;foo.tif&lt;/file&gt;
      &lt;/files&gt;
  &lt;/folder&gt;
  </code></pre>
  
  <p>My Schematron:</p>
  
  <pre><code>&lt;schema xmlns="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"&gt;
  
  &lt;!-- XML/PDF Matches --&gt;
  
  &lt;pattern abstract="false" id="xmlPdfPair"&gt;
      &lt;rule context="folder/files//file"&gt;
          &lt;assert test="substring-before(.,'.xml') eq substring-before(.,'.pdf')"&gt;The XML or PDF (&lt;value-of select="."/&gt;) does not have a matching PDF or XML file.&lt;/assert&gt;
      &lt;/rule&gt;
  &lt;/pattern&gt;
  </code></pre>
  
  <p></p>
  
  <p>I want the rule to fire on the missing bar.pdf which should be present in the file. My Schematron is not doing the trick. I feel like I need a for-each construct here. Would the use of keys make this simpler?</p>