xsl-list
[Top] [All Lists]

Re: [xsl] "if-condition-return something" idiom : is it possible in XSLT ?

2014-06-17 02:27:19
On Mon, Jun 16, 2014 at 9:12 PM, Liam R E Quin liam(_at_)w3(_dot_)org <
xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

On Mon, 2014-06-16 at 13:00 +0000, Kerry, Richard 
richard(_dot_)kerry(_at_)atos(_dot_)net
wrote:
I tend to view (*) xsl:choose as similar to C's "switch", which needs
to do a single calculation to work out which branch to run.
(*)  I may well be wrong in this.....

xsl:choose is like a sequence of C if statements in practice, and is
what yu want for your C++-like example.

But I think it better to think of xsl:choose in the mathematical sense,
e.g.

 A := f(x)
       0 when x <= 1
      17 when x <= 7
       A(x - 1) . A(x - 2) when x^2 + 1 is prime
      31x / 7 otherwise

That is, I prefer to think of XSLT as a functional language in which one
is describing the end result rather than as a procedural language with
loops and returns.

There's no concept of an "early return" from a mathematical function,
nor from an XSLT one.


but the value of f(x) above depends on the order in which the sub-clauses
are evaluated. Is that permissible in a mathematical function?
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>