Subject: RE: [xsl] javascript, xsl and xml From: "Michael Kay" <mhk@xxxxxxxxx> Date: Fri, 6 Aug 2004 12:39:15 +0100 |
> 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] javascript, xsl and xml, Phillip Nicolson | Thread | Re: [xsl] javascript, xsl and xml, David Carlisle |
[xsl] Automatic generation of XSLT , Agnes Kielen | Date | Re: [xsl] javascript, xsl and xml, David Carlisle |
Month |