XSLT:Foreach迭代每个项目,但显示第一个项目的值?

Fou*_*our 1 xslt foreach

我有一个项目列表,我希望每个项目都成为一个网址.

列表:

 <root>
   <tags>
     <tag>open source</tag>
     <tag>open</tag>
     <tag>advertisement</tag>
     <tag>ad</tag>
   </tags>
 </root>
Run Code Online (Sandbox Code Playgroud)

XSLT:

<xsl:template match="*">
    <div class="tags">
      <xsl:for-each select="/post/tags/tag">
          <a href="#">
            <xsl:value-of select="//tag"/>
          </a>
      </xsl:for-each>
    </div>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)

输出:

  <div class="tags"> 
    <a href="#">open source</a> 
    <a href="#">open source</a> 
    <a href="#">open source</a> 
    <a href="#">open source</a> 
  </div> 
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

Ode*_*ded 5

更正确的XSLT方法是添加"标记"模板并修改原始文件:

<xsl:template match="*">
    <div class="tags">
        <xsl:apply-templates select="tag" />
    </div>
</xsl:template>

<xsl:template match="tag">
      <a href="#">
        <xsl:value-of select="."/>
      </a>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)