ILOG JRules User Guide > Integrating Application Data > Reference > Mapping Between XML Schema and Dynamic Classes > Schema Types > Default Constructor Dynamic Methods

This example shows how to map a default constructor. A method is generated for each dynamic class. This method sets the attributes with their default values, if they exist. The following example includes a function that adds an instance of a dynamic class Book, with the default attribute title equal to None.

Here is the schema:

<complexType name="book">
   <sequence>
     <element name="ident"/>
     <element name="title" minOccurs="0" default="None" />
   </sequence>
</complexType>

Here is the XOM representation:

Class Book extends IlrXmlObject
{
   String ident ;
   String title ;
   Book ();  // default constructor
}

And here is the ilrmain function:

function void ilrmain(Object o) {    
 
   // Add a new book, default value: ( ident = null, title="None" )
   insert ( new Book() );
}

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