嘿,我需要<a>使用 XML 1.0 将每个标记中的内容修剪到描述节点中的字符限制 20。这是XML
  <description> 
       This is text <a href="http://stackoverflow.com/posts/14718323/edit">http://stackoverflow.com/posts/14718323/edit</a>. 
       Also here is more text than we have another 
       <a href="http://stackoverflow.com/posts/14718323/edit">http://stackoverflow.com/posts/14718323/edit</a>.
  </description>
我需要它变成这样:
  <description> 
       This is text <a href="http://stackoverflow.com/posts/14718323/edit">http://stacko</a>. 
       Also here is more text than we have another 
       <a href="http://stackoverflow.com/posts/14718323/edit">http://stacko</a>.
  </description>
我可以做大部分的逻辑,但我在做一个“for-each”搜索描述节点并转换“each”<a>时遇到了麻烦。
这有意义吗?任何帮助表示赞赏。
** 编辑 2/7/13 *
根据这里提供的答案是我现在的位置。
   <xsl:template match="/">
     <xsl:apply-templates select="//description"/>
   </xsl:template>
   <xsl:template match="a">
    <a href="{@href}">
       <xsl:value-of select="substring(normalize-space(),1,20)"/>
    </a>
   </xsl:template>
问题是“应用模板”不起作用,因为我的 XSL 中有多个模板。我需要专门调用一个模板,所以我认为“调用模板”将是要走的路线。“调用模板”的唯一问题是我不知道如何指定要引用的特定 XML 节点。到目前为止,这是我如何破解它(deosn't work):
    <xsl:template match="/">
      <xsl:call-template name="trim_text"/>
     </xsl:template>
    <xsl:template name="trim_text" match="//description">
     <a href="{@href}">
       <xsl:value-of select="substring(normalize-space(),1,20)"/>
     </a>
    </xsl:template>
最初的“调用模板”需要在 a 中,<xsl:template match="/">因为这是在一个更大的函数中。所以我需要三样东西:
1) HREF 与 XML 中的内容保持一致
2)标签之间的文字<a>要修剪到20px
3) 我需要从一个更大的 xsl 模板中调用这个模板,该模板对 XML 做了很多转换。这将是大约 7 个模板调用。