ILOG JRules User Guide > Integrating Application Data > Reference > Mapping Between XML Schema and Dynamic Classes > Schema Types > Local Complex Types Mapped to Inner Classes

This example shows how to map embedded local complex types onto inner classes.

Note
The inner class policy is activated by default.

The example includes a rule named processBorrowedBook that matches "Smith" with the attribute surname of an instance of the inner class borrower.

Here is the schema:

<complexType name="borrowed-book">
  <sequence>
    <element name="ident" />
    <element name="borrower">
      <complexType>
        <sequence>
           <element name="name">
           <element name="surname">
        </sequence>
      </complexType>
    </element>
  </sequence>
</complexType>

Here is the excerpt from an XML document:

<borrowed-book>
  <ident>12345</ident>
  <borrower>
    <name>John</name>
    <surname>Smith</surname>
  </borrower>
</borrowed-book>

Here is the XOM representation:

class BorrowedBook extends IlrXmlObject
{
  class Borrower extends IlrXmlObject
  { 
     String name;
     String surname;
  };
  String ident;
  Borrower borrower;
} 

And here is the rule:

rule processBorrowedBook
{
   when {
        b: BorrowedBook (  );
        BorrowedBook.Borrower ( surname equals "Smith" ) from b.borrower;
   }
   then {
      ...
   }
}

Related Reference

Built-in Simple Types
Simple Type Mapping
Simple Types Derived from Other Simple Types
List and Union Types
Local Simple Types Mapped onto Inner Classes
Complex Types
Extension of Simple Type Content in Complex Types
Complex Type Restriction
Complex Type Extension
Default Constructor Dynamic Methods
Type Identifier Mapping