Retrieving reflection information on a user simple type
You can retrieve reflection information on simple types.
About this task
The following example includes a schema and the two rules displayZipCodePattern and displayInvalidIntervalFloat to show how to process reflection information on simple types.
Procedure
To process reflection information on a user simple type:
Use the following schema:
<simpleType name="zip-code">
<restriction base="string">
<pattern value="[0-9]{5}" />
</restriction>
</simpleType>
<simpleType name="interval">
<restriction base="float">
<minInclusive value="10"/>
<maxInclusive value="20"/>
</restriction>
</simpleType>
And here are the rules:
rule displayZipCodePattern
{
when {
m: IlrXmlModel ();
s: IlrXmlSimpleType() from m.getSimpleType ( null, "zip-code" );
}
then {
out.printn ( "zip-code pattern : " + s.getPattern() );
}
}
rule displayInvalidIntervalFloat
{
when {
m: IlrXmlModel ();
s: IlrXmlSimpleType() from m.getSimpleType ( "Interval" );
f: Float ( !s.isInstance ( this ) );
}
then {
out.println ( "Invalid float " + f );
}
}