2010-07-18 60 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