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

Maths functions in a stylesheet?

Subject: Maths functions in a stylesheet?
From: "Derek Hohls" <dhohls@xxxxxxxxxx>
Date: Fri, 25 Feb 2005 18:40:31 +0200
xsl maths functions
If any XSLT gurus could help with  this...

I have a "maths functions" stylesheet, adapted from another source -

<?xml version="1.0"?> 
<xsl:stylesheet 
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
 xmlns:xalan="http://xml.apache.org/xalan";
 xmlns:maths="http://www.mydomain.com/maths";
 extension-element-prefixes="maths"
 version="1.0">
<xalan:component prefix="maths" elements="rules" functions="sine cosine
abs pi">
 <xalan:script lang="javascript">         
   function sine(thisValue) {
     return Math.sin(thisValue);
   }
   function cosine(thisValue) {
     return Math.cos(thisValue);
   }
   function abs(thisValue) {
     return Math.abs(thisValue);
   }   
   function pi() {
     return 3.141592653589790;
   }                             
 </xalan:script>
</xalan:component>
 </xsl:stylesheet>

Called like this:

<?xml version="1.0"?>
<xsl:stylesheet 
 version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
 xmlns:xalan="http://xml.apache.org/xalan";
 xmlns:maths="http://www.mydomain.com/maths";
 extension-element-prefixes="maths"> 
 >
<xsl:include href="functions.xsl"/>  
<xsl:template match="/">
 <xsl:variable name="foo" select="maths:pi()" />
</xsl:template>
</xsl:stylesheet>

I get :

An Error Occurred
java.lang.RuntimeException: Unknown error in XPath.
cause: java.lang.RuntimeException: Unknown error in XPath.

when running this with Cocoon 2.1.5 (withe default build with Xalan).

Thanks
Derek

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.