title: loop through files in a directory based on a condition
body: <p>I've an XML like below. and it is named <code>title.xml</code>.</p>
  
  <pre><code>&lt;entry&gt;
  &lt;file name="AMR_1A.xml"&gt;&lt;/file&gt;
  &lt;file name="AMR_1B.xml"&gt;&lt;/file&gt;
  &lt;file name="AMR_1C.xml"&gt;&lt;/file&gt;
  &lt;file name="AMR_1D.xml"&gt;&lt;/file&gt;
  &lt;file name="AMR_1E.xml"&gt;&lt;/file&gt;
  &lt;file name="AMR_1F.xml"&gt;&lt;/file&gt;
  &lt;file name="AMR_1G.xml"&gt;&lt;/file&gt;
  &lt;file name="AMR_1H.xml"&gt;&lt;/file&gt;
  &lt;file name="AMR_2A.xml"&gt;&lt;/file&gt;
  &lt;file name="AMR_2B.xml"&gt;&lt;/file&gt;
  &lt;file name="AMR_2C.xml"&gt;&lt;/file&gt;
  &lt;file name="AMR_2D.xml"&gt;&lt;/file&gt;
  &lt;file name="AMR_2E.xml"&gt;&lt;/file&gt;
  &lt;file name="AMR_2F.xml"&gt;&lt;/file&gt;
  &lt;file name="AMR_2G.xml"&gt;&lt;/file&gt;
  &lt;/entry&gt;
  </code></pre>
  
  <p>and The files placed in a folder where this title.xml file is placed. And I've the below files also</p>
  
  <pre><code>idx_1.xml
  idx_2.xml
  </code></pre>
  
  <p>here i'm trying to do the below.</p>
  
  <p>first open <code>idx_X.xml</code> and using XSLT, i want to loop through files with reference to my title.xml. The condition is <code>the looping should be done only on the files where the number matches the number in filename, i.e. translate all the text in title.xml file and the idx file, and if they match, then it should be looped only through those files</code>, The xslt i tried is as below. But it is not working.</p>
  
  <pre><code>&lt;xsl:for-each select="document('C:\Users\u0138039\Desktop\MY\2014All\XML\title.xml')/entry/file[translate(translate(replace(@name,'[^a-zA-Z]', ''),'.xml',''),'_','') = translate(translate(replace(base-uri(),'[^a-zA-Z]', ''),'.xml',''),'_','')]"&gt;
                      &lt;xsl:value-of select="translate(normalize-space(replace(base-uri(document(concat('C:\Users\u0138039\Desktop\MY\2014All\XML\',./@name))//case[//star.page=regex-group(1)]), '^.*/', '')),'.xml','')"/&gt;
                  &lt;/xsl:for-each&gt;
  </code></pre>
  
  <p>please let me know how can i fix this.</p>
  
  <p>Thanks</p>