如何与 href 增量连接

How to concatenate with href increment

这是我正在寻找的输出

<a href="#value-1" title="name">link name</a>
<a href="#value-2" title="name">link name</a>
<a href="#value-3" title="name">link name</a>

我正在尝试以下

<a>
<xsl:attribute name="href">"{concat('#value-',position())}"</xsl:attribute>
<xsl:attribute name="title"><xsl:value-of select="name"/></xsl:attribute>
<xsl:value-of select="link name" />
</a>

我仍然无法增加 href 值。关于如何增加 href 值的任何指示?

你应该在这里使用 xsl:value-of,类似于输出 "name"

<xsl:value-of select="concat('#value-', position())" />

或者使用属性值模板,这就是大括号的用武之地

<a href="#value-{position()}" name="{name}">

花括号仅适用于属性值。