Re: Stray quote from <xsl:value-of/> causing a string termination err or

Subject: Re: Stray quote from <xsl:value-of/> causing a string termination err or
From: Dan Morrison <dman@xxxxxxxx>
Date: Sat, 10 Jun 2000 03:36:41 +1200
Banker, Arjun wrote:
> 
> In the web page I'm generating using XSL, I'm using javascript to write
> values from an XML file.  For example, it would be something like this:

Ah yes, Dynamic generation of Javascript. I now have several templates
which combine 3-4 Languages in one file.

Quickest work-around is to use " instead of ' in your code.

document.write("   <xsl:value-of select="row-header/"/> " );

It looks like crap at first glance, but XSL is quite happy with it.

You can go 
document.write("   <xsl:value-of select='row-header/'/> " );
If it feels tidier.

Otherwise consider validating your input data earlier in the process.
Stray apostrophies are no fun anyway so maybe you should be storing them
as (the numeric equivalent of) &apos; in your source.

But you're right, there should be a nice XSL way of doing it that can
handle the general case, and eliminate not only ' and " but newlines
too, as that will also kill javascript if you use it as in your example.

I'm sure someone else here can fill that in ...



:=====================:====================:
: Dan Morrison        : The Web Limited    :
:  http://here.is/dan :  http://web.co.nz  :
:  dman@xxxxxxxx      :  danm@xxxxxxxxx    :
:  04 384 1472        :  04 495 8250       :
:  025 207 1140       :                    :
:.....................:....................:
: If ignorance is bliss, why aren't more people happy?
:.........................................:


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


Current Thread