Re: [xsl] Escaping curly braces in an attribute

Subject: Re: [xsl] Escaping curly braces in an attribute
From: david_n_bertoni@xxxxxxxxxx
Date: Mon, 16 Jun 2003 22:49:59 -0700

"Charles White" <chuck@xxxxxxxxxxx> wrote:
> Well, I'm not sure it's a more elegant solution that just writing out the
> attribute element, but you could do this:
> <xsl:variable name="leftbrace"><![CDATA[{]]></xsl:variable>

What's the purpose of the CDATA section here?  It's not as if you can't
have a curly brace as the content of xsl:variable.  This seems like
obfuscation without any practical purpose.  And if you really need one of
these as a string, how about:

   <xsl:variable name="leftbrace" select="'{'"/>

That's likely more efficient than creating a result tree fragment.

Fortunately, in an AVT, you can escape the { and } characters by having two
of them:

   <a href="#" onclick="if (foo == false) {{bar = true; alert('ding');}}
   return false">Don't click me</a>


   "When an attribute value template is instantiated, a double left or
   right curly brace outside an expression will be replaced by a single
   curly brace."


 XSL-List info and archive:

Current Thread