tags:

views:

70

answers:

1

Hello,

I am writing an XSLT file to output some HTML onto a web page (using Sitecore CMS). I am running into a problem with the following:

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

This causes the following error:

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

Can anyone tell me how to fix this issue?

Thank you,

b3n

+5  A: 

I think the braces are used as a shortcut to evaluating an XSLT function when inside an attribute.

They are called "Attribute Value Templates":

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.

You can escape them by using {{ and }}.

This makes your snippet read:

<a href="../videos/video.flv" class="videolightbox jackie-hover" data="{{width:400,height:200}}" title="Title goes here">Text goes here</a>
fd
That worked perfectly, thank you!
b3n