title: Trim href in an HTML anchor node
body: <p>Hey I need to trim content within in each <code>&lt;a&gt;</code> tag to a character limit 20 within a description node using XML 1.0. Here is the XML</p>
  
  <pre><code>  &lt;description&gt; 
         This is text &lt;a href="http://stackoverflow.com/posts/14718323/edit"&gt;http://stackoverflow.com/posts/14718323/edit&lt;/a&gt;. 
         Also here is more text than we have another 
         &lt;a href="http://stackoverflow.com/posts/14718323/edit"&gt;http://stackoverflow.com/posts/14718323/edit&lt;/a&gt;.
    &lt;/description&gt;
  </code></pre>
  
  <p>What I need it to turn into is this:</p>
  
  <pre><code>  &lt;description&gt; 
         This is text &lt;a href="http://stackoverflow.com/posts/14718323/edit"&gt;http://stacko&lt;/a&gt;. 
         Also here is more text than we have another 
         &lt;a href="http://stackoverflow.com/posts/14718323/edit"&gt;http://stacko&lt;/a&gt;.
    &lt;/description&gt;
  </code></pre>
  
  <p>I can do most the logic, but I'm having trouble doing a "for-each" that searches through the description node and transforms "each" &lt; a >.</p>
  
  <p>Does this make sense? Any help appreciated. </p>
  
  <p>** EDIT 2/7/13 <em>*</em></p>
  
  <p>Based on the answers provided here is where I am at now.</p>
  
  <pre><code>   &lt;xsl:template match="/"&gt;
       &lt;xsl:apply-templates select="//description"/&gt;
     &lt;/xsl:template&gt;
  
     &lt;xsl:template match="a"&gt;
      &lt;a href="{@href}"&gt;
         &lt;xsl:value-of select="substring(normalize-space(),1,20)"/&gt;
      &lt;/a&gt;
     &lt;/xsl:template&gt;
  </code></pre>
  
  <p>The problem is "apply-templates" won't work because I have multiple templates in my XSL. I need to call a template specifically, so I assumed "call-template" would be the route to go. The only problem with "call-template" is I don't know how to specify an specific XML node to reference. Here is how I've hacked it so far (deosn't work):</p>
  
  <pre><code>    &lt;xsl:template match="/"&gt;
        &lt;xsl:call-template name="trim_text"/&gt;
       &lt;/xsl:template&gt;
  
      &lt;xsl:template name="trim_text" match="//description"&gt;
       &lt;a href="{@href}"&gt;
         &lt;xsl:value-of select="substring(normalize-space(),1,20)"/&gt;
       &lt;/a&gt;
      &lt;/xsl:template&gt;
  </code></pre>
  
  <p>The initial 'call-template' needs to be in a <code>&lt;xsl:template match="/"&gt;</code> because this is going in a much larger function. So I need 3 things:</p>
  
  <p>1) the HREF to stay consistent with what is in the XML</p>
  
  <p>2) The text between the <code>&lt;a&gt;</code> tag to be trimmed to 20px</p>
  
  <p>3) I need to call this template from inside a much larger xsl template which does a lot of transformation on the XML. This will be of around 7 template calls. </p>