2014-01-13 24 views
3

我有兩個帶有經度和緯度值的變量。 現在我想計算這些變量爲x和y值,但我需要餘弦函數。 XSL只支持加號,除法等......在xsl版本1.0中計算餘弦值

我怎樣才能在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 ??"/> 

感謝您的幫助!

回答

2

沒有爲標準的XSLT 1.0餘弦無功能,但檢查出EXSLT,特別是math:cos()功能:

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. 
2

如果您的處理器不支持EXSLT數學:COS()功能,可以仍然使用Taylor power series相當容易地計算它。

1

或者查看處理器的文檔,瞭解如何編寫/調用擴展功能。一些處理器(例如Apache Xalan)使調用Java庫函數非常簡單。

2

我相信Dimitre Novachev的FXSL 1.0庫包含純XSLT 1.0代碼來計算三角函數。擴展函數可能會更快,但純粹的XSLT實現更具可移植性。