Retrieving reflection information on a schema

You can retrieve reflection information on a schema.

About this task

The following example shows how to obtain reflection information on a schema:

Procedure

To obtain reflection information on a schema:

  1. For instructions on how to get an XML data driver, see Reading XML documents for the decision engine.
    IlrXmlDataDriver  driver = ... 
    IlrXmlModel xmlModel = driver.getXmlModel();
    
  2. Get information on simple types (facets).
    IlrXmlSimpleType sType = xmlModel.getSimpleType ( "myType" );
    IlrXmlConstraints ctrs = sType.getLocalConstraints ();
    
  3. Get XML information on complex types.
    IlrXmlClass cType = xmlModel.getClass ( "myClass" );
    int minoccurs = cType.getAttributeMinOccurs ( "attr1" );
    

Results

Here is the schema:

<?xml version="1.0"?>

<schema targetNamespace="http://www.ilog.com/jrules/training/truck">
  <element name = "TruckModel">
     <complexType>
        <sequence>
           <element name="name" type="string"/>
           <element name="licenseClass" type="string"/>
           <element name="capacity" type="float"/>
           <element name="thresholdFull" type="float"/>
        </sequence>
     </complexType>
  </element>
</schema>

And here is the rule:

rule Threshold
{
   when {
   ?tm: TruckModel(capacity > 8000);
   }
   then {
      modify ?tm {thresholdFull = 0.9;}
   }
}