Re: ODP: JESS: Problem when loading Rule as a String
"Ernest Friedman-Hill" <[email protected]>
| Newsgroups | gmane.comp.java.jess |
|---|---|
| Message-ID | <[email protected]> |
The way you're doing it is fine. Otherwise, you could continue to send
document fragments containing just a "defrule" element and then do this:
Rete engine = ...
JessSAXParser parser = new JessSAXParser(engine, "defrule");
parser.parse(...)
Yes, I know the Javadoc says otherwise, but it will work anyway.
On Jul 29, 2010, at 5:34 AM, Pierre de Leusse wrote:
> Thanks for the quick and good answer W.
>
> I've noticed that JessSAXParser expects a "rulebase" node and
> XMLVisitor
> doesn't provide that node but instead a "rule" one. Manually
> inserting the
> "rulebase" node (c.f. code below) seems to work. However this makes
> me think
> that there must be a better way to do this. With XMLWriter maybe?
>
> All the best,
> Pierre
>
> Code:
> if (element instanceof Defrule) {
> XMLVisitor toXML = new XMLVisitor((Defrule) element);
> String sTemp = "<rulebase>" + toXML.toString() +
> "</rulebase>";
> kbs.add(sTemp);
> }
>
>
>
> -----Wiadomość oryginalna-----
> Od: [email protected] [mailto:[email protected]] W
> imieniu Wolfgang Laun
> Wysłano: Wednesday, July 28, 2010 6:30 PM
> Do: [email protected]
> Temat: Re: JESS: Problem when loading Rule as a String
>
> If the String s contains XML, you should use a JessSAXParser. Jesp
> parses only .clp.
> -W
>
> On 28 July 2010 15:46, Pierre de Leusse <[email protected]> wrote:
>> Hello all,
>>
>>
>>
>> I receive a Jess rule through the network in XML format and when I
>> try to
>> load it in the Rete engine, it throws an error. I know the rule
>> itself is
>> valid.
>>
>>
>>
>> Am I doing something wrong?
>>
>>
>>
>> Thanks for the help and tips,
>>
>> Pierre
>>
>>
>>
>> Code:
>>
>> for (String s : rules){
>>
>> try {
>>
>> StringReader read = new StringReader(s);
>>
>> Jesp parser = new Jesp(read, Demo.engine.getEngine());
>>
>> parser.parse(false);
>>
>> } catch (JessException e) {
>>
>> e.printStackTrace();
>>
>> }
>>
>> }
>>
>>
>>
>> Error:
>>
>> Jess reported an error in routine Jesp.parseExpression.
>>
>> Message: Expected a '(', constant, or global variable at token '&'.
>>
>> Program text: & at line 22 in file <unknown>.
>>
>> at jess.Jesp.error(Unknown Source)
>>
>> at jess.Jesp.parseExpression(Unknown Source)
>>
>> at jess.Jesp.promptAndParseOneExpression(Unknown Source)
>>
>> at jess.Jesp.parse(Unknown Source)
>>
>> at jess.Jesp.parse(Unknown Source)
>>
>> at
>>
> agh
> .edu
> .pl.soa.yield.jess.middleware.Functional.putRules(Functional.java:100
> )
>>
>> at
>>
> agh
> .edu
> .pl.soa.yield.jess.middleware.test.FunctionalTest.testPutRules(Functi
> onalTest.java:59)
>>
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>
>> at
>>
> sun
> .reflect
> .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
> )
>>
>> at
>>
> sun
> .reflect
> .DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
> .java:25)
>>
>> at java.lang.reflect.Method.invoke(Method.java:597)
>>
>> at junit.framework.TestCase.runTest(TestCase.java:154)
>>
>> at junit.framework.TestCase.runBare(TestCase.java:127)
>>
>> at junit.framework.TestResult$1.protect(TestResult.java:106)
>>
>> at junit.framework.TestResult.runProtected(TestResult.java:124)
>>
>> at junit.framework.TestResult.run(TestResult.java:109)
>>
>> at junit.framework.TestCase.run(TestCase.java:118)
>>
>> at junit.framework.TestSuite.runTest(TestSuite.java:208)
>>
>> at junit.framework.TestSuite.run(TestSuite.java:203)
>>
>> at
>>
> org
> .eclipse
> .jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3T
> estReference.java:130)
>>
>> at
>>
> org
> .eclipse
> .jdt.internal.junit.runner.TestExecution.run(TestExecution.java:3
> 8)
>>
>> at
>>
> org
> .eclipse
> .jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRu
> nner.java:467)
>>
>> at
>>
> org
> .eclipse
> .jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRu
> nner.java:683)
>>
>> at
>>
> org
> .eclipse
> .jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.
> java:390)
>>
>> at
>>
> org
> .eclipse
> .jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner
> .java:197)
>>
>>
>>
>>
>>
>> Which seems to come from the following line in the XML
>>
>> <funcall>
>>
>> <name>></name>
>
>
>
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users
> [email protected]'
> in the BODY of a message to [email protected], NOT to the list
> (use your own address!) List problems? Notify [email protected]
> .
> --------------------------------------------------------------------
>
>
>
>
>
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users
> [email protected]'
> in the BODY of a message to [email protected], NOT to the list
> (use your own address!) List problems? Notify [email protected]
> .
> --------------------------------------------------------------------
---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences Phone: (925) 294-2154
Sandia National Labs
PO Box 969, MS 9012 [email protected]
Livermore, CA 94550 http://www.jessrules.com
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [email protected]'
in the BODY of a message to [email protected], NOT to the list
(use your own address!) List problems? Notify [email protected].
--------------------------------------------------------------------