xsl-list
[Top] [All Lists]

Re: Template/function libraries for measurement units.

2003-01-21 08:48:03
Date: Mon, 20 Jan 2003 21:52:22 -0800 (PST)
From: Dimitre Novatchev <dnovatchev(_at_)yahoo(_dot_)com>
Subject: Re: [xsl] Template/function libraries for measurement units.
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com

Yes, Dimitre's code demonstrates pure XSLT implementations with
particular
attention to efficiency through the use of functional programming
concepts.

It may take some effort to figure out how to safely extract the
templates you
need from the complete calculator application, but it is worth it, to
get the
most portable solution.


Thank you Mike and Michael for mentioning FXSL.


Conversion from degrees to radians is defined in the trignm.xsl module
like this:

 <xsl:variable name="deg2rads" select="$pi div 180"/>

and further down:

   <xsl:variable name="vRads"
    select="(($pUnit = 'rad') * $pX)
             + ((not($pUnit = 'rad')) * ($pX * $deg2rads))"/>

which means, that when we want to conver $pX degrees to radians, we'll
use:

$pX * $deg2rads



Conversion from radians to degrees is defined in the arctrignm.xsl
module in a similar way:

 <xsl:variable name="rad2degs" select="180 div $pi"/>

and further down:

   <!-- convert radians to degrees (when 'deg' specified) -->
   <xsl:value-of
    select="(($pUnit = 'rad') * $vradResult)
             + ((not($pUnit = 'rad')) * ($vradResult * $rad2degs))"/>

which means, that when we want to conver $pX radians to degrees, we'll
use:

$pX * $rad2degs


If one needs to work also with minutes and seconds, then this can be
added easily -- delete or multiply twice by 60.

Should one wait (how long?) until an extension function is provided by
his vendour or by a "standard extension function" and his vendour then
implements it? And hope to be portable?

Or just use the simple pure XSLT 1.0 expressions above?

I think everybody can easily find the correct answer.


=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>