Subject: Re: [xsl] javascript, xsl and xml From: Phillip Nicolson <pjn3@xxxxxxxxxxxxx> Date: 06 Aug 2004 12:00:24 +0100 |
David, thankyou for your reply - yes I should have been more specific (probably due to my lack of knowledge as to how to crack my problem) The xml I am trying to pass is well formed I believe, something along the lines of: <vs:Table role="out" xmlns:vs="http://www.ivoa.net/xml/VODataService/v0.4"> <vs:Table>sgas_event</vs:Table> <vs:Column> <Name>time_start</Name> <Description>Start time of the solar event.</Description> <vs:DataType arraysize="*">char</vs:DataType> </vs:Column> <vs:Column> <Name>time_peak</Name> <Description>Peak time of the solar event.</Description> <vs:DataType arraysize="*">char</vs:DataType> </vs:Column> <vs:Column> <Name>time_end</Name> <Description>End time of the solar event.</Description> <vs:DataType arraysize="*">char</vs:DataType> </vs:Column> ................. 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> 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 '<'... Any further assistance much appreciated so I can have a weekend without this troubling me! On Fri, 2004-08-06 at 11:52, David Carlisle wrote: > > I have a child window and am looking to pass some of the xml within it > to it's parent. > The problem is: any '<' '>' or '"' contained within the xml (as there > will be) causes the javascript function call to fail. > > Is there anyway in a stylesheet to pass xml into a function without the > contents of the xml causing problems? Do I need to convert every < to > < < to > etc - if so is there a quick way to do this? > > you wern't very specifc where your problem was, if > > ypu mean that you have in the xml source unquoted < then the input is > not well formed (ie, not XML) so will be a fatal error to any XML > application, not just XSLT. > > You can use < or equivalently put a CDATA section around teh whole > block as in > <foo><![CDATA[ > 1 < 2 < 3 > ]]></foo> > > To XSLT that is identical input to > > > > <foo> > 1 < 2 7gt; 3 > </foo> > > That's all about the input, but as you said "javascript function call to > fail". perhaps your problem is in the output. > > If you have some input quoted as above and copy it to a script block > in the output it will come out as > > <script> > 1 < 2 > 3 > </script> > > if you are using the xml output method or > > <script> > 1 < 2 < 3 > </script> > > if you are using the html output method which is teh default if the top > level output element is html in no-namespace. > > Quoting < and & in script elements is teh correct thing to do in XHTML > but if you send the file to a browser that doesn't know anything about > xhtml (like for instance IE) then it will trip over the quoting as > < does not mean < in an html script element as & is not markup there > so it literally means the four characters & l t ;. > > If you specify cdata-section-elements="script" in your stylesheet the > element will probably be output as > > <script><![CDATA[ > 1 < 2 < 3 > ]]></script> > which is equivalent as XHTML, as HTML it sould just be a syntax error as > < is not special inside an html <script> so <![CDATA[ should not start > a CDATA section, but you will probably find it works, although I think > best is to generate html using the html output method rather than rely > on spurious html browser parsing of xhtml files. > > David > > ________________________________________________________________________ > This e-mail has been scanned for all viruses by Star Internet. The > service is powered by MessageLabs. For more information on a proactive > anti-virus service working around the clock, around the globe, visit: > http://www.star.net.uk > ________________________________________________________________________ > -- Phillip Nicolson Department of Physics & Astronomy Phone: (0)116 2523581 University of Leicester Email: pjn3@xxxxxxxxxxxxx Leicester LE1 7RH Web: http://www.astrogrid.org
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] javascript, xsl and xml, David Carlisle | Thread | RE: [xsl] javascript, xsl and xml, Michael Kay |
Re: [xsl] javascript, xsl and xml, David Carlisle | Date | [xsl] Automatic generation of XSLT , Agnes Kielen |
Month |