我正在使用xalan java,我必須在xslt中計算sin()和cos()。這裏是我的榜樣如何在xslt中計算三角函數sin&cos
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:math ="http://www.w3.org/2005/xpath-functions/math"
extension-element-prefixes="math">
version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match = "root/module[start-with(@name, phase)]">
<xsl:variable name ="k" select ="0.0"=/>
<xsl:variable name = "angle" select ="math:cos(k)"/>
<theta x = "$angle">
</theta>
</xsl:template>
</xsl:stylesheet>
注:這就是我嘗試和失敗,你可以請提供一個例子如何計算XSLT三角函數只是示例方法。謝謝
那麼,使用像Saxon 9這樣的XSLT處理器(可以在Maven或Sourceforge上獲得)支持這些功能,而不是依賴Xalan,它從來沒有更新過支持1999年版本1.0之後的XSLT/XPath的任何開發。有了Saxon 9,獲得XSLT 2.0和XPath 3.0支持,並且在不久的將來可以使用Saxon 9.8或許支持XSLT 3.0和XPath 3.1。 –
@MartinHonnen你能舉幾個例子來計算xslt中的三角函數嗎 – Mudasir
如果你使用Xalan,你可以使用:http://exslt.org/math/functions/sin/index.html和http:// exslt。組織/數學/功能/ COS/index.html的。 –