Hi, I have replaced the line <java:condition> math.op1 > 0 and math.op2 > 0 </java:condition> with <java:condition> math.getOp1() > 0 </java:condition> still I am getting the same exception
Regards, chandu -----Original Message----- From: Mark Proctor [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 25, 2006 2:15 PM To: [email protected] Subject: Re: [drools-user] DroolsParserException You can only put valid java inside a <condition> 'and' is not valid java. Mark J, Chandra Sekhar wrote: > Hi, > > I am getting the following exception, when I try to read the rules ( > which are defined in the xml file ) from my java program > > org.drools.compiler.DroolsParserException > at org.drools.compiler.PackageBuilder.addPackageFromXml(Unknown > Source) > at com.sample.DroolsMathExp.readRule(DroolsMathExp.java:75) > at com.sample.DroolsMathExp.main(DroolsMathExp.java:21) > (null: 6, 56): cvc-elt.1: Cannot find the declaration of element > 'rule-set'. > > > Here are the xml and java files > ------------------------------------ > 'MathRulesXml.xml' > > <rule-set name="math rules" > xmlns="http://drools.org/rules" > xmlns:java="http://drools.org/semantics/java" > xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" > xs:schemaLocation="http://drools.org/rules rules.xsd > http://drools.org/semantics/java java.xsd"> > > <rule name="math rule1"> > <parameter identifier="math"> > > <class>com.sample.MathObj</class> > </parameter> > <java:condition> > math.op1 > 0 and math.op2 > 0 > </java:condition> > <java:consequence> > math.setResult( math.getOp1() + math.getOp2() ); > System.out.println( "op1 = "+ math.getOp1()); > System.out.println( "op1 = "+ math.getOp2()); > System.out.println( "op1 + op2 = "+ math.getResult()); > </java:consequence> > </rule> > > </rule-set> > ---------------------------------------------------------------------- > -- > -- > "DroolsMathExp.java" > > Reader source = new InputStreamReader( > DroolsMathExp.class.getResourceAsStream( "MathRulesXml.xml" ) ); > > PackageBuilder builder = new PackageBuilder(); > builder.addPackageFromXml(source); > > Package pkg = builder.getPackage(); > RuleBase ruleBase = RuleBaseFactory.newRuleBase(); > ruleBase.addPackage( pkg ); > > WorkingMemory workingMemory = ruleBase.newWorkingMemory(); > > MathObj obj1 = new MathObj(); > obj1.setOp1(20); > obj1.setOp2(10); > workingMemory.assertObject(obj1); > workingMemory.fireAllRules(); > > ---------------------------------------------------------------------- > -- > ------------ > Please correct me whether the xml file is correct or not, give me some > examples how to define rules in xml file. > > Which is the best option to define rules in the following, and why > 1) xml file > 2) drl file > 3) DRL with DSL file > 4) XL sheet > > Regards. > Chandrasekhar J > > --------------------------------------------------------------------- > To unsubscribe from this list please visit: > > http://xircles.codehaus.org/manage_email > > -- > This email has been verified as Virus free Virus Protection and more > available at http://www.plus.net > > --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
