title: XSLT Matching a template to change an attribute just once
body: <p>I have a document with a specific attribute (myId) for which the value needs to be updated whenever its value is zero.  The document looks like this</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;Summary&gt;
   &lt;Section myId="0"&gt;
    &lt;Section myId="0"&gt;
     &lt;Para&gt;...&lt;/Para&gt;
    &lt;/Section&gt;
    &lt;Section myId="5"&gt;
     &lt;Para&gt;...&lt;/Para&gt;
    &lt;/Section&gt;
   &lt;/Section&gt;
  &lt;/Summary&gt;
  </code></pre>
  
  <p>I am using a template to match the attribute myId in order to set it to a unique ID passed from a calling program but I only want to match one of the attributes in the document.  Any additional attributes with a value of zero will be updated by passing a different ID.
  My template I'm using looks like this:</p>
  
  <pre><code> &lt;xsl:template        match  = '@myId[.="0"]'&gt;
    &lt;xsl:attribute name = "{name()}"&gt;
     &lt;xsl:value-of select = "$addValue"/&gt;
    &lt;/xsl:attribute&gt;
   &lt;/xsl:template&gt;
  </code></pre>
  
  <p>The value addValue is a global parameter passed from the calling program.
  I've searched for an answer for a good part of the day but I'm unable to have this template be applied only just once.  The output replaces both myId values with the content of addValue.
  I've tried to match with '@myId[."0"][1]' and I've tried to use the position() function to to match but my template is always applied to all myId attributes that are zero.</p>
  
  <p>Is it possible to apply a matching template only once?</p>