Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

calculate cosine in xsl version 1.0

Tags:

xslt

xslt-1.0

I have two variables with longitude and latitude values. Now i want to calculate these variables into x and y values, but i need the cosine function for that. XSL only supports plus, divide and so on...

How i can calculate cosine in XSL 1.0?

<xsl:variable name="lat" select="some value"/>
<xsl:variable name="lon" select="some value"/>

<xsl:variable name="x" select="?? do some crazy calculate with cosine ??"/>
<xsl:variable name="y" select="?? do some crazy calculate with cosine ??"/>

Thanks for Help!

like image 246
XSLHater Avatar asked Feb 14 '23 03:02

XSLHater


2 Answers

I believe the FXSL 1.0 library from Dimitre Novachev includes pure XSLT 1.0 code to calculate trigonometric functions. An extension function would probably be faster, but a pure XSLT implementation is more portable.

like image 98
Michael Kay Avatar answered Mar 11 '23 07:03

Michael Kay


There is no function for cosine in standard XSLT 1.0, but check out EXSLT, specifically the math:cos() function:

Implementer Page: math.cos.html
Function Package: math.cos.zip

function syntax

number math:cos(number)
The math:cos function returns cosine of the passed argument in radians.
like image 42
kjhughes Avatar answered Mar 11 '23 08:03

kjhughes