| ILOG JRules User Guide > Integrating Application Data > Reference > Mapping Between XML Schema and Dynamic Classes > Schema Types > Complex Type Restriction |
Complex Type Restriction |
PREVIOUS NEXT |
In the following example, the complex type book represents a standard book and the complex type old-book is a restriction because a lexical pattern constraint (pattern value ="[0-9]{2}-[A-Z]{5}-[0-9]") has been added. The example includes a rule named processOldBook that matches "Hamlet" with the title of an OldBook object.
| Note |
The OldBook dynamic class does not redefine nor restrict the Book class attributes, even if the ident field is more restricted.
|
Here is the schema:
<complexType name= "book">
<sequence>
<element name="ident" type="string"/>
<element name="title" type="string" />
</sequence>
</complexType>
<complexType name="old-book">
<complexContent>
<restriction base="book">
<sequence>
<element name="ident">
<simpleType>
<restriction base="string">
<pattern value="[0-9]{2}-[A-Z]{5}-[0-9]">
</restriction>
</simpleType>
</element>
</sequence>
</restriction>
</complexContent>
</complexType>
Here is the XOM representation:
class Book extends IlrXmlObject
{
...
String ident;
String title;
...
}
class OldBook extends Book
{
...
}
And here is the rule:
rule processOldBook
{
when {
OldBook ( title equals "Hamlet" );
}
then {
...
}
}
| Copyright © 1987-2008 ILOG S.A. All rights reserved. Legal terms. Documentation homepage. | PREVIOUS NEXT |