2012-10-29 79 views
1

我有一个图像(内容)。 xsl:template匹配表达式不起作用..的xsl:模板匹配不与src属性</p> <pre><code>http://myPage/rss.gif </code></pre> <p>我wan't更改属性工作

<replace css:content="#content" css:theme=".content" /> 
<xsl:template match="img/@src[contains(., 'rss.gif')]"> 
    <xsl:attribute name="src">/++theme++myPackage/images/<xsl:value-of select="." /></xsl:attribute> 
</xsl:template> 

我在做什么错?

+0

您可能会得到'++ theme ++ myPackage/images/http:// myPage/rss.gif'。你做? – wolfrevo

+0

嗨...不,我什么也没得到。它不匹配。但图像存在 - > saromba

回答

0

在您的示例中,您选择一个img-tag,其中包含字符串rss.gifsrc-属性,该字符串可能是http://myPage/rss.gif

然后,您将一个属性src添加到img -tag,其值为字符串/++theme++myPackage/images/和原始值http://myPage/rss.gif的串联值。

原始值加上<xsl:value-of select="." /></xsl:attribute>。这将选择src-attribute的整个值!

因此你喜欢的东西:

<img id="content" src="/++theme++myPackage/images/http://myPage/rss.gif" /> 

出于测试目的,你可以先蒙山预期src -attribute添加img - 元素你的theme.html文件,并检查如果图像文件被访问。请检查您的内容文件中的src的值是否只包含要附加到/++theme++myPackage/images/的字符串。

顺便说一句,在你的例子中,你用类替换主题元素:css:theme=".content"。提醒一下,这将替换类content的所有元素。考虑使用id或较窄的选择器,例如div.content或更好div#someid.content

相关问题