468,774 Members | 2,641 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,774 developers. It's quick & easy.

firefox xslt math

Hi,
I am using an XSLT to generate an SVG client-side in Firefox. The user
opens an XML file in Firefox and sees a display.

In doing so, I have to convert from cartesian to polar coordinates, so I
need the sine and cosine functions. Firefox does not seem to recognize
the math: extensions (not too surprising) so I am using a series
expansion of the sin(x) function on the interval 0-90 degrees and
mapping any other value, and the cos function, into this interval with
simple arithmetic to calculate on the full 360 deg range. I use four
terms to get the accuracy I need.

Is there a faster/simpler way, given the constraints of having to use
xslt 1.0 with no extensions, which seems to be the case? or... is there
some way of generating some scripting code in the xslt which would
allow me to access javascript (for example) and still achieve the
'automagic' effect of opening an xml and seeing an svg display?

cheers

shaun
Nov 18 '06 #1
7 2026
why not use MathML for math?

shaun roe wrote:
Hi,
I am using an XSLT to generate an SVG client-side in Firefox. The user
opens an XML file in Firefox and sees a display.

In doing so, I have to convert from cartesian to polar coordinates, so I
need the sine and cosine functions. Firefox does not seem to recognize
the math: extensions (not too surprising) so I am using a series
expansion of the sin(x) function on the interval 0-90 degrees and
mapping any other value, and the cos function, into this interval with
simple arithmetic to calculate on the full 360 deg range. I use four
terms to get the accuracy I need.

Is there a faster/simpler way, given the constraints of having to use
xslt 1.0 with no extensions, which seems to be the case? or... is there
some way of generating some scripting code in the xslt which would
allow me to access javascript (for example) and still achieve the
'automagic' effect of opening an xml and seeing an svg display?

cheers

shaun
Nov 18 '06 #2
In article <11**********************@h54g2000cwb.googlegroups .com>,
"Chris Chiasson" <ch************@gmail.comwrote:
why not use MathML for math?
Is there a faster/simpler way, given the constraints of having to use
xslt 1.0 with no extensions, which seems to be the case? or... is there
some way of generating some scripting code in the xslt which would
allow me to access javascript (for example) and still achieve the
'automagic' effect of opening an xml and seeing an svg display?

cheers

shaun
Maybe I'm wrong, but as I understand it, MathML provides a way for
capturing the meaning of a math expression in a standard way so it can
be represented in a browser, but provides no engine for the evaluation
of a math expression..?
Nov 18 '06 #3
whoops, I thought you were using SVG to draw equations and stuff

:-]

Doesn't SVG itself have ways to represent (and animate) things like
arcs and circles?

I know that Firefox is capable of making javascript manipulate SVG
images, but I don't know how to do it myself.

shaun roe wrote:
In article <11**********************@h54g2000cwb.googlegroups .com>,
"Chris Chiasson" <ch************@gmail.comwrote:
why not use MathML for math?
Is there a faster/simpler way, given the constraints of having to use
xslt 1.0 with no extensions, which seems to be the case? or... is there
some way of generating some scripting code in the xslt which would
allow me to access javascript (for example) and still achieve the
'automagic' effect of opening an xml and seeing an svg display?
>
cheers
>
shaun

Maybe I'm wrong, but as I understand it, MathML provides a way for
capturing the meaning of a math expression in a standard way so it can
be represented in a browser, but provides no engine for the evaluation
of a math expression..?
Nov 18 '06 #4
shaun roe wrote:
is there
some way of generating some scripting code in the xslt which would
allow me to access javascript (for example) and still achieve the
'automagic' effect of opening an xml and seeing an svg display?
No, Firefox does not support extension functions for XSLT that are
written with script.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 18 '06 #5
shaun roe wrote:
Maybe I'm wrong, but as I understand it, MathML provides a way for
capturing the meaning of a math expression in a standard way so it can
be represented in a browser, but provides no engine for the evaluation
of a math expression..?
I believe that's correct. MathML is just a way of representing a
formula; while one could certainly write an evaluator (or solver),
that's a separate feature from MathML rendering.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Nov 18 '06 #6
Is there a faster/simpler way, given the constraints of having to use
xslt 1.0 with no extensions, which seems to be the case?
This just isn't the kind of task XSLT is optimized for, and support for
extensions (and the details of them) are always optional/nonportable...
I suspect your series-expansion solution is in fact the fastest portable
solution you're going to come up with in XSLT itself.

I suppose you could the XSLT generate Javascript into the HTML it's
producing, and then let the browser execute that as a second pass. Feels
ugly/fragile to me, but then again Javascript always strikes me that way.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Nov 18 '06 #7
You could use the sin() and cos() implementations in FXSL -- however FXSL
uses a lot the xxx:node-set() function, which AFAIR Firefox XSLT hasn't
implemented.

At least, you could have a look at the code of the XSLT implementations and
read the following article, describing it:

An XSL Calculator: The Math Modules of FXSL

at:
http://fxsl.sourceforge.net/articles...alculator.html

Now the efficiency question -- a few days ago I performed an experiment
compairing FXSL sin() and cos() implementation to that of Math.Sin() and
Math.Cos() in .NET

Surprisingly and very contrary to the existing beliefs, FXSL's timings were
about the same and not greater than the timings for the .Net
implementations.

I was running the FXSL test code with Saxon J 8.7.3

Another conclusion that statements such as:

"This just isn't the kind of task XSLT is optimized for"

are very often wrong!
Cheers,
Dimitre Novatchev

"shaun roe" <sh*******@wanadoo.frwrote in message
news:sh*****************************@news.wanadoo. fr...
Hi,
I am using an XSLT to generate an SVG client-side in Firefox. The user
opens an XML file in Firefox and sees a display.

In doing so, I have to convert from cartesian to polar coordinates, so I
need the sine and cosine functions. Firefox does not seem to recognize
the math: extensions (not too surprising) so I am using a series
expansion of the sin(x) function on the interval 0-90 degrees and
mapping any other value, and the cos function, into this interval with
simple arithmetic to calculate on the full 360 deg range. I use four
terms to get the accuracy I need.

Is there a faster/simpler way, given the constraints of having to use
xslt 1.0 with no extensions, which seems to be the case? or... is there
some way of generating some scripting code in the xslt which would
allow me to access javascript (for example) and still achieve the
'automagic' effect of opening an xml and seeing an svg display?

cheers

shaun

Nov 18 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Nicole Szymanski | last post: by
reply views Thread by Benjamin Jones | last post: by
4 posts views Thread by Schraalhans Keukenmeester | last post: by
3 posts views Thread by zakhan | last post: by
4 posts views Thread by simon.a.hulbert | last post: by
6 posts views Thread by Dennis | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.