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

RE: javascript, xsl and xml

Subject: RE: javascript, xsl and xml
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Fri, 6 Aug 2004 12:39:15 +0100
javascript unterminated string literal
> I then have my function in the stylesheet:
> 
> <xsl:element name="img">
>   <xsl:attribute    
> name="src">/astrogrid-portal/AGRightFrame.gif</xsl:attribute>
>    <xsl:attribute name="onclick">backToRightFrameDC('<xsl:value-of
> select="@val"/>');
>    </xsl:attribute>
> </xsl:element>

You don't really have a function in the stylesheet, all you have is text,
which an HTML browser is going to treat as a function provided you generate
correct code.
> 
> Onclicking the image to call the function I get
> 
> Error: unterminated string literal
> Source Code:
> backToRightFrameDC('<vodescription><vr:Resource
> xmlns:vr="http://www.ivoa.net/xml/VOResource/v0.9"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:type="RegistryType">
> 
> with the unterminated string literal occuring at the 1st '<'...

You've missed out a stage: what does the HTML you are generating look like?
Looking at the JavaScript error messages that you get when you execute it is
not the best way of finding the errors in your stylesheet.

Generally, I would advise generating very simple function calls within
attributes like onClick(). The main logic should go in the <script> sections
that these functions invoke. This gives you far fewer problems with escaping
of special characters.

There are still issues with doing things like

document.write('<a>')

within a <script> section, but on the whole you can leave the XSLT processor
to sort out whether or not the angle brackets should be escaped.

Michael Kay

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.