Reading XML documents (decision engine)

After deserialization, XML documents can be read and represented as XML objects for use with the decision engine.

About this task

During deserialization, an XML object is created from an XML document. The XML document can then be read and represented as an IlrXmlObject instance. Errors are raised if the document format is not valid.

Procedure

  1. Call the engine definition. An engine definition is similar to a ruleset in the classic rule engine. From an engine definition, you can access rules or tasks, and create an executable engine.
    EngineDefinition definition = ...  
  2. Write this code in a try-catch block to catch possible read errors.
    XmlBindingService xmlBindingService = definition.getService(XmlBindingService.class);
    IlrXmlDataDriver driver = xmlBindingService.getDataDriver();
    try {
       IlrXmlObject obj = driver.readObject(new FileReader(xmlFilename)); 
    } catch ( IlrXmlErrorException e ) {
    
    }
    The try command returns the root XML object of the XML file.

Results

Here is the entire code sample:
EngineDefinition definition = ...  
XmlBindingService xmlBindingService = definition.getService(XmlBindingService.class);
IlrXmlDataDriver driver = xmlBindingService.getDataDriver();
try {
   IlrXmlObject obj = driver.readObject(new FileReader(xmlFilename)); 
} catch ( IlrXmlErrorException e ) {

}