[XSL-LIST 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

Subject: RE: How do we call Javascript function in XSL file on Netscape(Ver 6.2) browser?
From: "Deshpande, Gururaj" <gururaj.deshpande@xxxxxxxxxxxx>
Date: Wed, 10 Apr 2002 13:46:23 -0400
gururaj deshpande
Hi Charles,

I am copying my XSL and XML files. Can you find out the problem?

<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="equipment.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>
------------------------------------------
<?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>Equipment No.</td>
		    <td>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>
---------------------------------------------------------

> Hi Gururaj
> 
> One thing, one of your table elements wasn't closed in your sample, but
> also, the stuff in curly braces in your a href where your Javascript
> function is being called is, I'm assuming, being interpreted as an
> attribute
> value template. I haven't tested your code, but that's probably it.
> Anything
> in an attribute value surrounded by {} gets interpeted as an AVT, in other
> words, an expression.
> 
> regards,
> 
> Charles White
> CEO
> The Tumeric Partnership
> http://www.tumeric.net
> chuck@xxxxxxxxxxx
> ________________________________________
> Author, Mastering XSLT
> Sybex Books, May, 2002
> 
> Co-Author, Mastering XML, Premium Edition
> Sybex Books, May, 2001
> http://www.javertising.com
> 
> ----- Original Message -----
> From: "Deshpande, Gururaj" <gururaj.deshpande@xxxxxxxxxxxx>
> To: <XSL-List@xxxxxxxxxxxxxxxxxxxxxx>
> Sent: Wednesday, April 10, 2002 7:45 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
> >
> > xsl file
> > <?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>
> >          <title></title>
> >       </head>
> > <link rel="stylesheet" type="text/css"
> > href="../html/SparesCat.CSS"></link>
> > <SCRIPT language="JavaScript"><![CDATA[
> > function test(avalue) {
> > alert(avalue);
> > }
> >       ]]></SCRIPT>
> >       <body>
> > <table>
> > <tr>
> >     <td>Equipment No..</td>
> >     <td>Description.</td>
> >     <td>Manufacture No..</td>
> >     <td>Contract No.</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 valign="middle" class="TableGrey">
> > <td><a href="javascript:test('{prodxml}')"><xsl:value-of
> > select="equipmentno"/></a></td>
> >     <td><xsl:value-of select="description"/></td>
> >     <td><xsl:value-of select="manufactureno"/></td>
> >     <td><xsl:value-of select="contractno"/></td>
> > </tr>
> > </xsl:for-each>
> > </xsl:template>
> > </xsl:stylesheet>
> >
> >
> >  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> >
> >
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

 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.