This is a known bu... ah, "idiosyncrasy" of Jess that I've mentioned
here before. To access a defglobal on the LHS of a rule, you need to
use the (get-var) function :

(test (call (get-var *NodeClass*) isInstance ?node))

I think Dave Carlson wrote:
> 
> This out-of-context example from my XML code posted earlier appears to be a
> bug with the 'call' function.  As shown here, the parser throws an error for
> this rule, but I believe it's valid code.
> 
> (defglobal ?*NodeClass* = (call java.lang.Class forName "org.w3c.dom.Node"))
> 
> (defrule GetFirstChild
>   (Node (firstChild ?node))
>   (test (call ?*NodeClass* isInstance ?node))
>  =>
>   (definstance Node ?node)
> )
> 
> Rete Exception in routine ReteCompiler::eval.
>   Message: Unbound variable found in funcall: *NodeClass*  at line 24:  ( defrul
> e GetFirstChild ( Node ( firstChild ?node ) ) ( test ( call ?*NodeClass* isInsta
> nce ?node ) ) = > ( definstance Node ?node ) ) .
>         at java.lang.Throwable.<init>(Compiled Code)
>         at java.lang.Exception.<init>(Compiled Code)
>         at jess.ReteException.<init>(ReteException.java:26)
>         at jess.ReteCompiler.compilerError(ReteCompiler.java:830)
>         at jess.ReteCompiler.eval(Compiled Code)
>         at jess.ReteCompiler.addRule(Compiled Code)
>         at jess.Rete.addDefrule(Compiled Code)
>         at jess.Jesp.doParseDefrule(Compiled Code)
>         at jess.Jesp.parseDefrule(Compiled Code)
>         at jess.Jesp.parseSexp(Compiled Code)
>         at jess.Jesp.parse(Compiled Code)
>         at jess.Main.main(Compiled Code)
> 
> ---------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the
> list. List problems? Notify [EMAIL PROTECTED]
> ---------------------------------------------------------------------
> 
> 


---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
Org. 8920, MS 9214                  [EMAIL PROTECTED]
PO Box 969                  http://herzberg.ca.sandia.gov
Livermore, CA 94550

---------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list. List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------

Reply via email to