无法使用substring-after属性设置xsl:variable

时间:2015-02-04 07:04:51

标签: xml xslt xslt-1.0

我对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"/>

我做错了什么?

0 个答案:

没有答案
相关问题