ILOG JRules User Guide > Integrating Application Data > Tasks > Using the XML Binding API > Using XML Objects as Ruleset Parameters

Ruleset parameters enable you to exchange data between your ruleset and an external application. You will notice that there is no difference in the way XML objects and Java objects are handled.

To set an XML object as a ruleset parameter:

  1. Create an XML object:
IlrXmlObject xmlObject = ... //your object
See also Reading an XML Document.
  1. Declare parameters direct to the rule engine using IlrContext, by setting the parameters before setting the rules. Use setParameterValue to identify the name of the ruleset parameter:
IlrContext engine = ...
IlrXmlObject xmlObject = ...
engine.setParameterValue( "myXmlParameter", xmlObject ) ;
engine.execute ();
You can use setParameters to set parameters by providing a map, thereby creating an association between the name and the value.

When using XML binding with Rule Execution Server, you can pass the parameters direct, as a String. The rule session API (ilog.rules.bres.session) provides an interface that converts your parameters from String to XML before passing them to the rule engine. Conversely, an output parameter is returned automatically as a String.

Use the following method to execute the rules in a stateful session:

IlrSessionExecutionResult executeRules(IlrSessionStatefulExecutionSettings executionSettings)

Use the following method to execute the rules in a stateless session:

IlrSessionResponse executeRules(IlrSessionRequest)

The session parameter setting would then be:

IlrSessionRequest sessionReq = ...;
IlrSessionExecutionSettings execSet = sessionReq.getExecutionSettings();
IlrSessionParameteres inputParams = execSet.getInputParameters();
inputParams.setParameter("xmlP", myXmlString);

Using this API you only need to pass the String. You do not need to deal with the XML driver. The rule session API provides access to the engine, and as a result conceals the IlrContext API.

Each parameter available in the rule session should have been declared in Rule Studio. For more information, see Creating Ruleset Parameters.

Related Concepts

XML Binding
Ruleset Parameters

Related Tasks

Adding XML Objects to the Working Memory
Assigning the Root Element Name of an XML Object
Reading an XML Document
Writing to an XML Document
Creating Ruleset Parameters