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

Accessing the JavaScript Math object

Subject: Accessing the JavaScript Math object
From: "Chris Bayes" <Chris@xxxxxxxxxxx>
Date: Mon, 14 May 2001 17:27:12 +0100
javascript math
Hi All,
I want to be able to use the JavaScript Math object like so
Cos 1 = <xsl:value-of select="math:cos(1)" />
I could do this from outside the transform

myProc.input = xmldoc;
myProc.addObject(Math, "urn:JavaScript:Math");
myProc.transform();

and in my transform

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:math="urn:JavaScript:Math"
>
...
Cos 1 = <xsl:value-of select="math:cos(1)" />

But I want to use an xml-stylesheet PI so I can't do this.
So I want to be able to do something like
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:math="urn:schemas-microsoft-com:JavaScript-Math"
>
...
Cos 1 = <xsl:value-of select="math:cos(1)" />

but I can't.
The closest I seem to be able to get is

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:math="urn:schemas-microsoft-com:JavaScript-Math"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
>
	<msxsl:script language="JavaScript" implements-prefix="math">
	    function cos(arg){ return Math.cos(arg);}
  	</msxsl:script>
	<xsl:template match="/">
		<html>
		<body>
		Cos 1 = <xsl:value-of select="math:cos(1)" />
		</body>
		</html>
	</xsl:template>
</xsl:stylesheet>

But this means that I have to write wrappers for all the methods and
properties of the Math object which I don't have to do if I use addObject
So how do I access the Math object or any other JavaScript intrinsic object
in my xslt?

Ciao Chris

XML/XSL Portal
http://www.bayes.co.uk/xml


 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.