How to check if an element name contains a specific string in XSLT and then rename those elements?
<p>I have an XML file that contains several elements named FileName1, FileName2, FileName3, and so on. I need to check the document for these element names and then rename them "FileName".</p>

<p>Here's the XML:</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;ProcessData&gt;
  &lt;Transformed&gt;
    &lt;ConnectionZone&gt;Internal&lt;/ConnectionZone&gt;
    &lt;Directory&gt;/Test/Inbox&lt;/Directory&gt;
    &lt;FTPProfileID&gt;XYZ&lt;/FTPProfileID&gt;
    &lt;FileName1&gt;Test1.txt&lt;/FileName1&gt;
    &lt;FileName2&gt;Test2.txt&lt;/FileName2&gt;
    &lt;MoveDirectory&gt;/Test/MovedFiles&lt;/MoveDirectory&gt;
    &lt;Operation&gt;MV&lt;/Operation&gt;
    &lt;RenameExt&gt;.csv&lt;/RenameExt&gt;
  &lt;/Transformed&gt;
&lt;/ProcessData&gt;
</code></pre>

<p>Here's what I have in the XSLT so far:</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"&gt;

&lt;xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" /&gt;
&lt;xsl:strip-space elements="*"/&gt;

&lt;xsl:template match="/"&gt;
    &lt;table&gt;
        &lt;xsl:if test="//*[contains(name(), 'FileName']"&gt;
            &lt;xsl:element name="FileName"&gt;
        &lt;/xsl:if&gt;     
    &lt;/table&gt;
&lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;
</code></pre>

<p>Nothing I try has proven successful so far. I can't seem to get any matches in my xsl:if statement.</p>

<p>Please let me know if you can think of a better way to perform this! I just need to remove the last character (digit) of each element name that contains "FileName".</p>

<p>Thanks!</p>