title: XSL partial match on Name
body: <p>Using a single xsl template, how can one perform a partial match on a <code>@Name</code> field?</p>
  
  <p>Now, I am working with a <a href="http://www.codeproject.com/Articles/424763/Zen-and-the-art-of-XSLT-rendering-fields-SharePoin" rel="nofollow noreferrer">custom Sharepoint <code>fldtypes.xsl</code> file</a>.</p>
  
  <p>There is a <a href="https://stackoverflow.com/questions/14057312/how-to-match-this-or-that-in-an-xsl-template">very nice answer here</a> about how to match on multiple names, but I want to match <em>any</em> field that has "phone" in the name - such as:</p>
  
  <ul>
  <li>Primary Phone</li>
  <li>Secondary Phone</li>
  <li>Alt phone</li>
  <li>phone</li>
  <li>Phone</li>
  <li>Cell phone<br>
  <em>(etc....)</em></li>
  </ul>
  
  <p>Here is my current template, which works for exact matches:</p>
  
  <pre><code>&lt;!-- Turn Phone number fields into callto links--&gt;
  &lt;xsl:template match="FieldRef[contains('|phone|Phone|', concat('|',@Name,'|') )]" mode="Text_body"&gt;
      &lt;xsl:param name="thisNode" select="."/&gt;
      &lt;xsl:variable name="currentValue" select="$thisNode/@*[name()=current()/@Name]" /&gt;
      &lt;xsl:choose&gt;
          &lt;xsl:when test="$currentValue=''"&gt;
              &lt;span&gt;&lt;/span&gt;
          &lt;/xsl:when&gt;
          &lt;xsl:otherwise&gt;
              &lt;a href="callto:{$currentValue}" class="calltolink" target=""&gt;&lt;xsl:value-of select="$currentValue" /&gt;&lt;/a&gt;
          &lt;/xsl:otherwise&gt;            
      &lt;/xsl:choose&gt;
  &lt;/xsl:template&gt; 
  </code></pre>