|
[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: How do we call Javascript function in XSL file on Netscape
Hi Jeff,
The XSL transform works fine as far as display is concerned. It shows the
data and hyperlink, the way I expected. But when I click on the hyperlink,
Netscape shows error 'test is not defined' in the javascript console.
Another pointer: If I change the function name to alert() instead of
test(), Netscape pops up the message. I think what this means is that
Netscape does not understand or recognise <script> block or function in the
script block.
Thanks
Gururaj
> -----Original Message-----
> From: Jeff Greif [SMTP:jgreif@a...]
> Sent: Wednesday, April 10, 2002 4:22 PM
> To: Deshpande, Gururaj
> Subject: Re: How do we call Javascript function in XSL file
> on Netscape (Ver 6.2) browser?
>
> What do you actually see in Netscape? Do you see what you expect and only
> the javascript doesn't work, or is there a chance that XSLT wasn't used at
> all?
> Jeff
> ----- Original Message -----
> From: "Deshpande, Gururaj" <gururaj.deshpande@f...>
> To: "'Jeff Greif'" <jgreif@a...>; <xml-dev@l...>
> Sent: Wednesday, April 10, 2002 1:08 PM
> Subject: RE: How do we call Javascript function in XSL file on
> Netscape (Ver 6.2) browser?
>
>
> > I am sorry. Please read my last sentence as "But Netscape is NOT
> generating
> > HTML using MSXML !!"
> >
> > - Gururaj
> >
> > --------------------------------------------
> > > I am clicking on the hyperlink and then test() function is called.
> > >
> > > I changed the <script> element as you described and still does not
> work.
> > >
> > > This is the html I got in MSXML. I saved this into file and opened in
> > > Netscape and works fine. But Netscape is generating HTML using MSXML
> !!
> > > <html>
> > > <head>
> > > <META http-equiv="Content-Type" content="text/html; charset=UTF-16">
> > > <SCRIPT type="text/javascript"><!--
> > > function test(avalue) {
> > > alert(avalue);
> > > }
> > > --></SCRIPT></head>
> > > <body>
> > > <table border="1">
> > > <tr>
> > > <td>Equipment No.</td>
> > > <td>Description</td>
> > > </tr>
> > > <tr>
> > > <td><a href="javascript:test('prod39.xml')">010.AS100</a></td>
> > > <td>High-top airslide 300 12 200</td>
> > > </tr>
> > > <tr>
> > > <td><a href="javascript:test('prod38.xml')">010.AS200</a></td>
> > > <td>Low-bottom airslide 200 12 100</td>
> > > </tr>
> > > <tr>
> > > <td><a href="javascript:test('prod37.xml')">010.AS300</a></td>
> > > <td>No-bottom airslide 200 12 100</td>
> > > </tr>
> > > </table>
> > > </body>
> > > </html>
> > >
> > > [Jeff wrote]
> > > > Looks OK to me, and works for me in IE6, except that in recent HTML
> you
> > > > are
> > > > supposed to use
> > > > <SCRIPT type="text/javascript">
> > > > instead of
> > > > <SCRIPT language="JavaScript">
> > > > The language attribute still exists but is deprecated. It's
> possible
> > > that
> > > > Netscape also uses a case-sensitive spelling of javascript (I don't
> have
> > > a
> > > > copy of Netscape handy.) The way to try this is to use a separate
> XSLT
> > > > processor (MSXSLT or Xalan from apache.org or something else), run
> it
> on
> > > > your xml file, putting the html output into a file. Then stick the
> html
> > > > result into Netscape separately and see what happens. You could
> also
> > > try
> > > > changing the SCRIPT element as described above and see if it makes
> any
> > > > difference.
> > > >
> > > > Also, your description of the problem is a bit inaccurate. Your XSL
> > > > transform is *emitting* javascript, not calling it. The javascript
> > > > functions are only called when someone clicks on an item in the
> rendered
> > > > HTML.
> > > >
> > > > Jeff
> > > > ----- Original Message -----
> > > > From: "Deshpande, Gururaj" <gururaj.deshpande@f...>
> > > > To: "'Jeff Greif'" <jgreif@a...>
> > > > Sent: Wednesday, April 10, 2002 10:39 AM
> > > > Subject: RE: How do we call Javascript function in XSL
> file
> on
> > > > Netscape (Ver 6.2) browser?
> > > >
> > > >
> > > > > Hi Jeff,
> > > > >
> > > > > I am copying my XSL and XML file. What is wrong with this?
> > > > >
> > > > > --------------------------------
> > > > > <?xml version='1.0' encoding="iso-8859-1"?>
> > > > > <xsl:stylesheet version="1.0"
> > > > > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> > > > > <xsl:output method="html"/>
> > > > > <xsl:template match="/">
> > > > > <html>
> > > > > <head>
> > > > > <SCRIPT language="JavaScript"><![CDATA[
> > > > > function test(avalue) {
> > > > > alert(avalue);
> > > > > }
> > > > > ]]></SCRIPT>
> > > > > </head>
> > > > > <body>
> > > > > <table border="1">
> > > > > <tr>
> > > > > <td width="15%" align="center">Equipment No.</td>
> > > > > <td width="50%" align="center">Description</td>
> > > > > </tr>
> > > > > <xsl:apply-templates select="plant/dept/eqpt"/>
> > > > > </table>
> > > > > </body>
> > > > > </html>
> > > > > </xsl:template>
> > > > > <xsl:template match="plant/dept/eqpt">
> > > > > <xsl:for-each select=".">
> > > > > <tr>
> > > > > <td><a
> > > > > href="javascript:test('{prodxml}')"><xsl:value-of
> > > > > select="equipmentno"/></a></td>
> > > > > <td><xsl:value-of select="description"/></td>
> > > > > </tr>
> > > > > </xsl:for-each>
> > > > > </xsl:template>
> > > > > </xsl:stylesheet>
> > > > >
> > > >
> >
> >
> --------------------------------------------------------------------------
> > > > > <?xml version="1.0" encoding="iso-8859-1"?>
> > > > > <?xml-stylesheet type="text/xsl" href="..\html\equipment-1.xsl"?>
> > > > > <plant>
> > > > > <dept deptid="231">
> > > > > <eqpt eqptid="39">
> > > > > <equipmentno>010.AS100</equipmentno>
> > > > > <description>High-top airslide 300 12
> 200</description>
> > > > > <prodxml>prod39.xml</prodxml>
> > > > > </eqpt>
> > > > > <eqpt eqptid="38">
> > > > > <equipmentno>010.AS200</equipmentno>
> > > > > <description>Low-bottom airslide 200 12
> 100</description>
> > > > > <prodxml>prod38.xml</prodxml>
> > > > > </eqpt>
> > > > > <eqpt eqptid="37">
> > > > > <equipmentno>010.AS300</equipmentno>
> > > > > <description>No-bottom airslide 200 12
> 100</description>
> > > > > <prodxml>prod37.xml</prodxml>
> > > > > </eqpt>
> > > > > </dept>
> > > > > </plant>
> > > > >
> > > > >
> > > > > > The html document your XSLT transform is creating is invalid
> > > according
> > > > to
> > > > > > the HTML 4.01 DTD. The only allowed content for the HTML
> element
> is
> > > > > > (HEAD,
> > > > > > BODY). You probably meant to put the link and SCRIPT elements
> into
> > > > the
> > > > > > HEAD
> > > > > > element. Perhaps Netscape 6.2 is more standards-compliant and
> > > refuses
> > > > to
> > > > > > accept illegal HTML? It is useful in cases like these to run
> the
> > > > output
> > > > > > of
> > > > > > the style sheet through the W3C 'tidy' program.
> > > > > >
> > > > > > Jeff
> > > > > > ----- Original Message -----
> > > > > > From: "Deshpande, Gururaj" <gururaj.deshpande@f...>
> > > > > > To: <xml-dev@l...>
> > > > > > Sent: Wednesday, April 10, 2002 8:11 AM
> > > > > > Subject: How do we call Javascript function in XSL
> file
> on
> > > > > > Netscape (Ver 6.2) browser?
> > > > > >
> > > > > >
> > > > > > > To, all XML Gurus
> > > > > > > My question is about Netscape 6.2, XSL, XML and Javascript. I
> am
> > > > doing
> > > > > > > client side transformation. No server support at all. When I
> call
> > > > > > javascript
> > > > > > > function within XSL file, Netscape does not run / understand
> the
> > > > > > javascript.
> > > > > > > Same works on IE without problems.
> > > > > > > I am copying my XSL file below.
> > > > > > > Does anybody has a solution? Thanks
> > > > > > > Gururaj
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > >
> > > -----------------------------------------------------------------
> > > The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> > > initiative of OASIS <http://www.oasis-open.org>
> > >
> > > The list archives are at http://lists.xml.org/archives/xml-dev/
> > >
> > > To subscribe or unsubscribe from this list use the subscription
> > > manager: <http://lists.xml.org/ob/adm.pl>
> >
> > -----------------------------------------------------------------
> > The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> > initiative of OASIS <http://www.oasis-open.org>
> >
> > The list archives are at http://lists.xml.org/archives/xml-dev/
> >
> > To subscribe or unsubscribe from this list use the subscription
> > manager: <http://lists.xml.org/ob/adm.pl>
> >
> >
> >
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|
|||||||||

Cart








