Re: [xsl] More-than-basic maths

Subject: Re: [xsl] More-than-basic maths
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Sat, 19 Mar 2005 09:24:12 +1100
On Fri, 18 Mar 2005 15:25:11 -0400 (CLT), andrew cooke <acooke@xxxxxxxx> wrote:
> 
> just following up on this, in case anyone googles for info as i was doing.
> 
> - while the fxsl library works for simple tasks, it fails on more complex
> operations when using saxon 8.3 (both fxsl-1.2 and fxsl for xsl 2).
> 
> - with xalan, fxsl-1.2 does work (so there seems to be a problem with
> saxon), but, it turns out, xalan supports exslt (extended xsl) which gives
> you access to math:... functions, which have a nicer syntax than fxsl (at
> least, as far as i understood things).
> 
> so the simplest solution seems to be to use xalan with the exslt math
> extensions.

As I already explained in reply to your private message, there are
three things to note here:

   1). The FXSL version for XSLT 1.0, if run with an XSLT 2.0
processor such as Saxon 8.x, Saxon.NET or Gestalt, may produce
incorrect results or more likely error messages. This is simple: FXSL
for XSLT 1.0 is for XSLT 1.0

   2). I recommend that FXSL for XSLT 2.0 is used with an XSLT 2.0
processor such as Saxon 8.x, Saxon.NET or Gestalt. Using this version
of FXSL, it is better to use an available xsl:function over an
available xsl:template. For example, use:

          <xsl:value-of select="f:arcsin(1 div ., 0.000001, 'deg')"/>


Do not use:

    <xsl:call-template name="arcsin">
      <xsl:with-param name="pX" select="1 div ."/>
      <xsl:with-param name="pUnit" select="'deg'"/>
    </xsl:call-template>


At this moment there is an issue with Saxon 8.3, due to which some
transformations using FXSL are not performed correctly. Using
Saxon.NET and Saxon 8.2 produces correct results.

A side note for using EXSLT. Generally it is not correct to compare
the two libraries as they have considerably different scope and goals.
I would recommend using an EXSLT function over a corresponding FXSL
function if 100% portability is not a goal of the XSLT application,
your XSLT processor supports EXSLT and there is an EXSLT function that
you can use.

Even in this case one will use FXSL for functions that are provided by
FXSL but are missing in EXSLT and as a powerful mechanism to construct
new functions from old available ones.

Remember that FXSL makes it possible to use almost every XPath
2.0(/XSLT 2.0) function and operator as a higher order function --
thus the main result of using FXSL + XSLT 2.0 is a closed pure XSLT
2.0 functional programming system where (almost) every function is a
Higher-Order one (HOF), it is easy to write any new xsl:function as a
HOF and almost any function can be converted (wrapped as a) to a HOF.


Cheers,
Dimitre Novatchev.

Current Thread