我对xslt的经验非常有限,所以我似乎无法在这里找到问题。
在XML中,我有多次出现不同的graphic
元素,如下所示:
<graphic xlink:href="someVariableText-gf01.tif"/>
<graphic xlink:href="someVariableText-gf02.tif"/>
<graphic xlink:href="someVariableText-gf03.tif"/>
我需要更改xlink:href
,保留-gf
之后的唯一数字。
我的代码如下:
<xsl:template match="graphic/@xlink:href">
<xsl:variable name="aftergf" select="substring-after(., 'gf')"/>
<xsl:attribute name="xlink:href">
<xsl:value-of select="concat('MyNewText-gf', $aftergf)"/>
</xsl:attribute>
</xsl:template>
给我:
<graphic xlink:href="MyNewText-gf"/>
<graphic xlink:href="MyNewText-gf"/>
<graphic xlink:href="MyNewText-gf"/>
我做错了什么?