XSL - 替换时无效的Xpath扩展

时间:2009-10-01 11:41:00

标签: xslt

当我尝试使用以下内容时出现错误:

<xsl:variable name="url" select="guid"/>        
<xsl:variable name="vid" select="substring-after($url,'podcast/')"/>
<xsl:variable name="pre" select="substring-before($vid,'.mp4')"/>

<<xsl:variable name="p" select="replace($pre,'_','-')"/>
<xsl:variable name="p1" select="concat($p,'.embed_thumbnail.jpg')"/>
<xsl:variable name="p2" select="concat('http://images.ted.com/images/ted/tedindex/embed-posters/',$p1)"/>

任何人都可以看到问题,这一切对我来说都很好吗?

3 个答案:

答案 0 :(得分:1)

您使用的是XSLT 1处理器吗? replace函数出现在XPath 2.0中,因此在XSLT 1中不可用。

在这种情况下,您可以改为使用translate函数。

答案 1 :(得分:0)

p变量的定义之前,你有一个额外未转义的小于号:

<<xsl:variable name="p" select="replace($pre,'_','-')"/>

这不是有效的语法。

您应该删除它:

<xsl:variable name="p" select="replace($pre,'_','-')"/>

或逃避它:

&lt;<xsl:variable name="p" select="replace($pre,'_','-')"/>

答案 2 :(得分:0)

我看到'&lt;&lt;&lt;在第4行的开头,是吗?