RE: [rules-users] Parsing XML using Drools
by Anstis, Michael (M.)
I am not sure on what you are trying to achieve.
Drools is a Rule Engine and not a XML parser; the nearest I could find
to what you are reporting ("I know XML Streaming is possible in Drools")
is the following.
http://netzooid.com/blog/2007/03/16/sxc-simple-xml-compiler-jaxb-runtime
-streaming-xpath-implementation-and-more/
Can you enlighten me with your knowledge of XML Streaming in Drools?
________________________________
From: Gupta, Ankit (Ankit) [mailto:gupta11@avaya.com]
Sent: 29 January 2009 10:04
To: Anstis, Michael (M.)
Subject: RE: [rules-users] Parsing XML using Drools
Hi Mike,
Thanks for prompt reply ,
Actually right now I am streaming the xml
<BenchmarkResultsFor>
<Benchmark>DataProcessing</Benchmark>
<Workload>1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16</Workload>
<Memory>4, 4, 4, 8, 8, 12, 12, 16, 24, 24, 24, 24, 24, 24,
24, 24</Memory>
</BenchmarkResultsFor>
here we are using apache math api for interpolation
public MemoryBenchmarkResult(String name, double[] x, double[]
y) {
this.hostFunction = name;
// Create the interpolation function
SplineInterpolator i1 = new SplineInterpolator();
this.workload = x;
this.memory = y;
this.interpolator = i1.interpolate(this.workload, this.memory);
}
here we are passing the values of X Axis (Workload) and we get
the values of Y Axis (Memory ). Reading or Streaming of this XML are
doing using SAX .
This thing I want to do with Drools ...... as I know XML
Streaming is possible in Drools .
Regards
Ankit
________________________________
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Anstis,
Michael (M.)
Sent: Thursday, January 29, 2009 2:48 PM
To: Rules Users List
Subject: RE: [rules-users] Parsing XML using Drools
It is not clear how you want to use the XML?
If the XML represents Facts then you could use a worker Fact and
"FROM" to deserialise them and make them available to WM. For example:-
rule "get some XML facts"
when
$w : Worker()
Cheese( ) from $w.getCheesesFromXML();
then
//Do something with cheese
end
Obviously the XML need not be true serialised objects (in a JAXB
sense) but simply the properties that "getCheeseFromXML" rehydrates.
Drools is not exposing any of the XML libraries; they are merely
used by your code. The above would be (partially) equivalent to:-
Worker w = new Worker();
List<Cheese> cheeses = w.getCheesesFromXML();
for(Cheese c : cheeses) {
wm.insert(c);
}
rule "Cheese pre-loaded"
when
Cheese( )
then
//Do something with cheese
end
Partially equivalent as you could retract Cheese( ) in the
second way which would affect truth maintenance whereas the first way
would (I believe) not.
With kind regards,
Mike
________________________________
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Gupta, Ankit
(Ankit)
Sent: 29 January 2009 07:22
To: rules-users(a)lists.jboss.org
Subject: [rules-users] Parsing XML using Drools
Hi All,
How can we read and parse a XML file using
drools ?
Does Drools support the SAX or DOM parsing .
Regards
Ankit
16 years, 10 months
How to setup Foreach node?
by Cristiano Gavião
Hi, I would like to know how can I setup a ForEach composite.
I setup two variables on accountProcess.rf properties (main flow
diagram). One is the Account class, and other is a
java.util.Collection<Account>.
I fill the variable and collection expression on the ForEach node
with those variables. But Im still getting these errors:
ForEach node 'Every Account' [8] has no collection expression.
ForEach node 'Every Account' [8] has no variable name.
Im missing something or I did something wrong?
ah, I almost forget.... When I have a ForEach node on a flows diagram,
the layout isn't saved. I mean, if I close the diagram and open It
again, the ForEach node will be on a different place.
thanks in advance
_________________________
Cristiano V. Gavião
"Tudo vale a pena se a alma não é pequena..." Fernando Pessoa
16 years, 10 months
RuleFlow question
by Steven Williams
Hi guys,
I am playing with the OrderExample in drools-examples and was wondering how
I get access in my rules to the parameters that are sent to startProcess?
e.g.
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("order", order);
parameters.put("orderId", order.getOrderId());
parameters.put("email", emailTextField.getText());
ProcessInstance processInstance =
ksession.startProcess("org.drools.examples.process.ruleset.RuleSetExample",
parameters);
I have access to the ProcessInstance but there doesn't seem to be any clear
path to the parameters.
thanks
Steve
16 years, 10 months
Globals
by Femke De Backere
Hi!
I'm trying to set a global for my ruleflow in Drools 5 M5.
Patient patient = new Patient();
ksession.setGlobal("patient", patient);
But I always get the following error:
"Could not find variable scope for variable patient when trying to
execute Work Item Human Task
Continuing without setting parameter."
Does anyone know what I'm doing wrong?
Thx!
Femke
16 years, 10 months
How can i achieve below in Guvnor or Drools
by Ashish Soni
Hi All ,
I am not sure if below structure is supported in Drools 5 or Guvnor or is
there is any way we can achieve this -
We want to create packages structure like below under the packages panel ,
as of now every package comes under the packages tab but how can we have a
multiple package root element with different names -
As per the below there are parent default rules and function which may or
may not be applicable to states ( child's ) and then each child also have
their own rules and functions
Countries
USA
- Default Rules
- Default functions
- MA
- Rules
- Functions
--
--
-Arizona
- Rules
- Functions
-NY
- Rules
- Functions
United Kingdom
- Default Rules
- Default functions
- State 1
- Rules
- Functions
--
--
-State 2
- Rules
- Functions
-State 3
- Rules
- Functions
Please suggest.
Regards,
Ashish Soni
16 years, 10 months
Need Help
by yash kapoor
Hi All, I want to execute the example PricingRuleDTExample.java
contains in drools-examples-drl-4.0.x
This file read the the ExamplePolicyPricing.xls file ,when I am running it
gives the following error
Exception in thread "main" java.lang.RuntimeException: Script template is
null - check for missing script definition.
at org.drools.decisiontable.model.SnippetBuilder.build(Unknown Source)
at org.drools.decisiontable.parser.ActionType.getSnippet(Unknown Source)
at org.drools.decisiontable.parser.RuleSheetListener.createCondition(Unknown
Source)
at org.drools.decisiontable.parser.RuleSheetListener.nextRule(Unknown
Source)
at org.drools.decisiontable.parser.RuleSheetListener.processRuleCell(Unknown
Source)
at org.drools.decisiontable.parser.RuleSheetListener.newCell(Unknown Source)
at org.drools.decisiontable.parser.xls.ExcelParser.handleText(Unknown
Source)
at org.drools.decisiontable.parser.xls.ExcelParser.processRecord(Unknown
Source)
at
org.apache.poi.hssf.eventusermodel.HSSFRequest.processRecord(HSSFRequest.java:136)
at
org.apache.poi.hssf.eventusermodel.HSSFEventFactory.genericProcessEvents(HSSFEventFactory.java:170)
at
org.apache.poi.hssf.eventusermodel.HSSFEventFactory.processEvents(HSSFEventFactory.java:101)
at org.drools.decisiontable.parser.xls.ExcelParser.parseFile(Unknown Source)
at org.drools.decisiontable.SpreadsheetCompiler.getRuleSheetListener(Unknown
Source)
at org.drools.decisiontable.SpreadsheetCompiler.compile(Unknown Source)
at
org.drools.examples.PricingRuleDTExample.executeExample(PricingRuleDTExample.java:40)
at
org.drools.examples.PricingRuleDTExample.main(PricingRuleDTExample.java:29)
I do not know .....what is wrong in XLS file here I am attaching the code in
zip format .
Any suggestion/comment will appreciated.
Regards
Yash
16 years, 10 months
Not looping the rule when more then 1 valid match is found
by Maxim Veksler
Hello group,
Assuming I have the rule:
rule "try not to loop"
when
$a : A($code : code)
$b : B(parentCode == $code)
then
addResult($a, $b);
end
and the classes:
public class A {
int code;
}
public class B {
int parentCode;
}
I insert into the WM 4 objects :
A(code = 1), A(code = 2);
B(parentCode=1), B(parentCode = 2);
I would like that after calling fireAllRules() only 1 match will be
returned. I have no preference regarding which one, in the current situation
2 matches are returned.
Anyone could suggest a method to enforce this ?
Thank you,
Maxim.
16 years, 10 months
Failover setup with BRMS
by Michael Finger
Hey everyone,
We're looking at putting the BRMS backed by an Oracle RBDMS into
production and the issue of failover has come up.
As things will move from QA into production using export/import,
clustering so someone's
work isn't lost if a server goes down isn't a big concern.
Ideally we would just like to put a load balancer in front of the BRMS
servers, point the rule agent
at the load balancer url, and be done with it. I've been trying to find
some info on how this word.
In particular, what happens if I import a new package into BRMS server
1. When would server 2 see the new package and server them out? What
about existing packages that are updated? When would these changes
propagate?
Also, I noticed the following param in the rule agent config:
*
url
This is a space separated list of URLs to the BRMS which is
exposing the packages (see below for more details).
What is the expected behavior when you list multiple URLS?
Thanks,
Michael Finger
Overstock.com
CONFIDENTIALITY NOTICE: This message is intended only for the use and review of the individual or entity to which it is addressed and may contain information that is privileged and confidential. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message solely to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify sender immediately by telephone or return email. Thank you.
16 years, 10 months
Working with dates in rules
by David Siefert
Hi-
I'm wondering how it would be possible to compare a part of a date in the
lhs condition of a rule in a Drool. In other words, I need to compare a
date to see if it is *x* days from the current date, *n* hours from current
time, etc. Would anyone be kind enough to provide an example? I'm thinking
I may have to implement something of my own to offer that functionality?
Big thanks,
David
16 years, 10 months