Download User Manual
Transcript
OpenRules® User Manual
OpenRules, Inc.
This method will execute two other methods, "addGreetingRules" and
"addSalutationRules", that will read the above xml-files and will add the proper
rule tables to the newly created ExternalRules object.
Before reading the xml files, we have to specify the proper xml schemas in the
Environment table placed in the main Excel file HelloXMLRules.xls:
Environment
import.java
com.openrules.table.external.Objects
file:rules/xml/GreetingRules.xml
import.schema
file:rules/xml/SalutationRules.xml
OpenRules®
dynamically
defines
the
Java
classes,
GreetingRules
and
SalutationRules, that will be used to read the proper XML files.
Now we may specify the method "addGreetingRules":
Method ExternalRules addGreetingRules(ExternalRules externalRules)
GreetingRules greetings =
GreetingRules.load("file:rules/xml/GreetingRules.xml");
Objects[] grid = new Objects[greetings.Rule.length];
for(int i = 0; i < greetings.Rule.length; ++i) {
GreetingRules.Rule r = greetings.Rule[i];
Objects row = new Objects(3);
row.set(0,r.from); row.set(1,r.to); row.set(2,r.greeting);
grid[i] = row;
}
externalRules.addRuleTable(greetings.ruleTableName,
greetings.templateName, grid );
First we load the rules from the xml-file defining its relative path using the
standard OpenRules® URL notation:
file:rules/xml/GreetingRules.xml
All objects specified in the file GreetingRules.xml becomes available to the Java
code
through
the
object
"greetings"
of
the
dynamically
defined
type
GreetingRules. In particular, the object "greetings.Rule" points to the array of
objects of the dynamic type "Rule" as it was defined in the xml-file.
20