Fwd: Predicates order of evaluation

Ihe Onwuka <[email protected]> Tue, 15 Sep 2020 19:22:36 -0400
Newsgroups gmane.text.xml.saxon.help,gmane.text.xml.xsl.general.mulberrytech
Message-ID <CALfs7+wdfpvSQ77jWjtF9LRE2hRkw4SPrbk94m18xfGKAwFDsw@mail.gmail.com>
---------- Forwarded message ---------
From: Michael Kay <mike-JkSD5nQpfvpWk0Htik3J/[email protected]>
Date: Tue, Sep 15, 2020 at 6:07 PM
Subject: Re: [saxon] Predicates order of evaluation
To: <[email protected]>



Seeing as you can recast A[B] as  (if B then A else ())  does that mean it
depends on how you write it?


You can only do that rewrite if B is focus-independent.




Ok a[b] as in a[parent::*] where a is a function or expression that fails
if the context node does not have a  parent element


>
Here you have a predicate that's focus dependent. Generally you can't know
whether a node has a parent until you know what node it is; there's a
functional dependency so a has to be evaluated first. But if the system can
make static inferences then all bets are off. For example if the expression
is

/[parent::*]

then the processor might infer statically that it has to be an empty
sequence because a root node never has a parent, which means it's
unpredictable whether this will throw an error in cases where evaluation of
"/" fails (e.g if the context item is a parentless element).

Michael Kay
Saxonica

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[email protected]
https://lists.sourceforge.net/lists/listinfo/saxon-help