Re: [xsl] How to dynamically evaluate an equation in the input XML document?

Subject: Re: [xsl] How to dynamically evaluate an equation in the input XML document?
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 14 Jul 2021 18:57:37 -0000
On 14.07.2021 20:48, Roger L Costello costello@xxxxxxxxx wrote:
<Convert-to-Celsius>
     <equation>(Fahrenheit - 32) * (5/9)</equation>
     <variable>
         <name>Fahrenheit</name>
         <value>32</value>
     </variable>
</Convert-to-Celsius>

<xsl:template match="*[equation]"> <xsl:evaluate xpath="fold-left(variable, equation => replace('/', ' div '), function($e, $v) { replace($e, $v/name, $v/value) })" context-item="()"/> </xsl:template>

seems to work but of course it all depends on the grammar of your
equation and the grammar for variables, the operators used and how to
"translate" them to XPath operators.

Current Thread