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

Re: Stray quote from <xsl:value-of/> causing a string termin

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
javascript encode quote input xsl
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

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.