Return to doc.sitecore.com

Valid for Sitecore 5.3, 5.2
Why Is a Rendering Not Executing Certain Statements?

The XSL specification defines Attribute Value Templates to allow XPath statements to be executed from within non-XSL constructs (section 7.6.2 of http://www.w3.org/TR/xslt#attribute-value-templates at the time of this writing). In short, curly braces indicate attribute value templates which must be used where an XPath statement should be evaluated within an attribute value (quoted value) in a non-XSL construct (angle bracket not followed by the xsl namespace).  For instance, the XPath expression sc:path( . ) in the following statement is evaluated without the need for curly braces as it is contained within an element in the xsl namespace (<xsl:value-of>):

<xsl:value-of select="sc:path( . )" />

In the following statement, the XPath expression must be enclosed in curly braces as it is within an attribute value in an element which is not in the XSL namespace (<a>):

<a href="{sc:path( . )}">

If a token in a non-XSL construct is not interpreted as an attribute value template, it will be output literally to the result stream.  For instance the following statement:

<a href="sc:path( . )">

will write this exact text to the output stream instead of substituting the path of the item into the attribute value.
If needed, double-curly braces can be used to represent literal curly braces where a single curly brace would otherwise result in an a token being interpreted as an attribute value template.
Attribute value templates can generally be avoided by using the <xsl:element> and <xsl:attribute> constructs:

<xsl:element name="a">
  <xsl:attribute name="href"><xsl:value-of select="sc:path( . )" /></xsl:attribute>

Another reason why tokens might be output literally instead of interpreted by the XSLT engine is that XSL extension controls such as <sc:text /> (http://sdn.sitecore.net/Developer/Sitecore%20and%20XSL/XSL%20Extension%20Controls.html) cannot be used within XSL function libraries (http://sdn.sitecore.net/Articles/XSL/Creating%20Libraries.html - see http://sdn.sitecore.net/Articles/XSL/Creating%20Libraries/Notes.html). XSL extension functions (http://sdn.sitecore.net/Developer/Sitecore%20and%20XSL/XSL%20Extension%20Functions.html) must be used in libraries instead; Sitecore XSL extension functions provide a superset of the features available in Sitecore XSL extension controls.  For instance the following statement in an XSL function library:

<sc:text field="title" />

will write this exact text to the output stream instead of retrieving the value of the title field from the context item; instead use:

<xsl:value-of select="sc:fld( 'title', . )" />