Reading XML documents (classic rule engine)

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

About this task

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

Procedure

  1. Call the model that represents the XML document.
    IlrReflect model = ...  
  2. Write a try-catch block to catch possible read errors.
    try {
      
       driver.setModel ( model );
       Reader reader = new FileReader ("xmlFile.xml");
       IlrXmlObject myObject = driver.readObject (reader);
    
    } catch ( IlrXmlErrorException e ) {
    
    }
    The try command returns the root XML object of the XML file. The driver.setModel ( model ); instruction is not necessary if the schema is already loaded.

Results

Here is the entire code sample:
IlrReflect model = ...  try {
  
   driver.setModel ( model );
   Reader reader = new FileReader ("xmlFile.xml");
   IlrXmlObject myObject = driver.readObject (reader);

} catch ( IlrXmlErrorException e ) {

}