[thelist] escaping { and } in XSL

Eric Vitiello evolt at perceive.net
Thu Mar 7 06:25:01 CST 2002


-- Jason Bauer [Wed, 06 Mar 2002 15:07:40 -0500]:
>At 12:16 PM 3/6/02 -0500, you wrote:
>>i have an XSL page that writes some JS functions, but the way the
>>JS functions are written, it's causing the XSL parser to think they
>>are variables, and therefore blows up...
>>
>>how does one escape { and } in XSL?
>
>I've never had a problem with the brackets in XSL before, perhaps
>there is something else in your JavaScript that the parser isn't liking. The
>only things you should need to escape are < (&lt;) > (&gt;) and & (&amp;)
>
>If you've got all of that taken care of and it still doesn't work,
>you could always put the javascript in <xsl:text></xsl:text> tags so it
>isn't parsed...

you should make sure to put your script in a CDATA block. i.e:


<script language="JavaScript" type="terxt/javascript">
<![CDATA[
	function blah() {
		var someVariable = 1;
	}
]]>
</script>


the CDATA block tells the XSL parser not to parse that block, and to pass it directly as-is to the output.

---
Eric Vitiello
Perceive Designs
<www.perceive.net>




More information about the thelist mailing list