Package: xpath-sys

Macro define-xpath-function/lazy

Lambda List

define-xpath-function/lazy (ext name args &body body)


  • ext -- name of an XPath extension (a symbol)
  • name -- XPath function name
  • args -- XPath function arguments


Defines an XPath function, "lazy" style.

The body is evaluated during compilation of XPath expressions each time the function being defined is referenced. It's passed a list of "thunks" corresponding to XPath function arguments and should return a new "thunk". A "thunk" is a function that takes an XPath context as argument and returns value of one of XPath types (string, boolean, number, node set).

   (define-xpath-function/lazy my-ext my-if (v if-part else-part)
     #'(lambda (ctx)
         (if (boolean-value (funcall v ctx))
             (funcall if-part ctx)
             (funcall else-part ctx))))   

See also