2010-07-18 105 views
4

我正在编写一个XSLT文件来将一些HTML输出到网页上(使用Sitecore CMS)。我遇到一个问题如下:XSLT渲染问题HTML

<a href="../videos/video.flv" class="videolightbox jackie-hover" data="{width:400,height:200}" title="Title goes here">Text goes here</a>

这会导致以下错误:

Expected token '}', found ':'. {width -->:<-- 400,height:200}

谁能告诉我如何解决这个问题?

谢谢

B3N

回答

6

我认为括号是用来作为快捷方式,当一个属性内的评价XSLT的功能。

他们被称为 “属性值模板”:

Attribute value templates in XSLT are the XPath expressions that appear in curly braces in attribute values. Without this extremely convenient shortcut, we'd be forced to use the xsl:attribute instruction whenever we needed to dynamically compute an attribute's value.

您可以通过使用{{}}逃避它们。

这使你的代码片段阅读:

<a href="../videos/video.flv" class="videolightbox jackie-hover" data="{{width:400,height:200}}" title="Title goes here">Text goes here</a> 
+0

,完美的工作,谢谢! – b3n 2010-07-18 23:56:11