Complex type restriction
The XOM takes complex type restrictions into account in the XOM.
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 {
…
}
}