This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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


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@es.co.nz      :  danm@web.co.nz    :
:  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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]