[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Escaping curly braces in an attribute

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



"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>

See:

   http://www.w3.org/TR/xslt#attribute-value-templates

   "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."

Dave


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.