title: how to use an if for have a condition with few characters in an attribute value with XSLT 1.0
body: <p>I have an XML I need to match one text node (my XSLT my xslt already does that), and then if the last 4 characters of the the attribute value is equal to something I need to add a new attribute into the tag.</p>
  <p>This the XML that I have</p>
  <pre><code>&lt;LT&gt;
      &lt;identifications&gt;
          &lt;identification title=&quot;Delivery1&quot;&gt;
              &lt;Direction name=&quot;DFD_45_FLO&quot;&gt;
                  &lt;ready&gt;yes&lt;/ready&gt;
                  &lt;indice&gt;1&lt;/indice&gt;
              &lt;/Direction&gt;
          &lt;/identification&gt;
          &lt;identification title=&quot;Delivery2&quot;&gt;
              &lt;Direction name=&quot;KJI_45_PTS&quot;&gt;
                  &lt;ready&gt;yes&lt;/ready&gt;
                  &lt;indice&gt;0&lt;/indice&gt;
              &lt;/Direction&gt;
              &lt;/identification&gt;
          &lt;identification title=&quot;Delivery3&quot;&gt;
              &lt;Direction name=&quot;DFASDF_552_FLO&quot;&gt;
                  &lt;ready&gt;yes&lt;/ready&gt;
                  &lt;indice&gt;0&lt;/indice&gt;
              &lt;/Direction&gt;
              &lt;/identification&gt;
      &lt;/identifications&gt;
  &lt;/LT&gt;
  
  </code></pre>
  <p>And I want to match yes and after that if the last characters of the attribute name is FLO_ then copy the entire node an add the attribute paid=&quot;check&quot; to the tag direction, in that way I would have an output like :</p>
  <pre><code>&lt;LT&gt;
      &lt;identifications&gt;
          &lt;identification title=&quot;Delivery1&quot;&gt;
              &lt;Direction name=&quot;DFD_45_FLO&quot; paid=&quot;check&quot;&gt;
                  &lt;ready&gt;yes&lt;/ready&gt;
                  &lt;indice&gt;1&lt;/indice&gt;
              &lt;/Direction&gt;
          &lt;/identification&gt;
          &lt;identification title=&quot;Delivery3&quot;&gt;
              &lt;Direction name=&quot;DFASDF_552_FLO&quot; paid=&quot;check&quot;&gt;
                  &lt;ready&gt;yes&lt;/ready&gt;
                  &lt;indice&gt;0&lt;/indice&gt;
              &lt;/Direction&gt;
              &lt;/identification&gt;
      &lt;/identifications&gt;
  &lt;/LT&gt;
  
  </code></pre>
  <p>I have this XSLT, and it already do the first part but I dont know how to match the last characters with the if.</p>
  <pre><code>&lt;xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;&gt;
  &lt;xsl:output method=&quot;xml&quot; version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; indent=&quot;yes&quot;/&gt;
  &lt;xsl:strip-space elements=&quot;*&quot;/&gt;
  
      &lt;xsl:template match=&quot;@*|node()&quot;&gt;
        &lt;xsl:copy&gt;
          &lt;xsl:apply-templates select=&quot;@*|node()&quot;/&gt;
        &lt;/xsl:copy&gt;
      &lt;/xsl:template&gt;
  
      &lt;xsl:template match='Direction[ready/text()=&quot;yes&quot;]'&gt;
      &lt;xsl:if test=&quot;@name='last characters = FLO'&quot;&gt; THIS IS THE LINE I DONT KNOW HOW TO WRITE
        &lt;xsl:copy&gt;
          &lt;xsl:apply-templates select=&quot;@*&quot;/&gt;
          &lt;xsl:attribute name=&quot;paid&quot;&gt;check&lt;/xsl:attribute&gt;
          &lt;xsl:apply-templates select=&quot;node()&quot;/&gt;
        &lt;/xsl:copy&gt;
      &lt;/xsl:if&gt;
      &lt;/xsl:template&gt;
  
      
  &lt;/xsl:stylesheet&gt;
  </code></pre>