Processing reflection information on a user complex type
You can retrieve reflection information on complex types.
About this task
The following example includes a schema and two rules displayCollectionAttribute and displayIntXmlElement to show how to process reflection information on complex types.
Procedure
To process reflection information on a user complex type:
Use the following schema:
<complexType name="person"/>
<sequence>
<element name="name"/>
<element name="surname" maxOccurs="4"/>
<element name="age" type="int"/>
</sequence>
</complexType>
And here are the rules:
rule displayCollectionAttribute
{
when {
m: IlrXmlModel ();
c: IlrXmlClass() from m.getClass ( "Person" );
attr: String ( c.isUnaryAttribute(this) ) in c.getAttributes();
}
then {
out.println ( "collection attribute : " + attr );
}
}
rule displayIntXmlElement
{
when {
m: IlrXmlModel ();
c: IlrXmlClass() from m.getClass ( "Person" );
attr: String ( ) in c.getAttributes();
IlrXmlType ( getXmlName() equals "int" )
from c.getAttributeComponentType ( attr );
}
then {
out.println ( "int element : " + c.getAttributeXmlName ( attr ) );
}
}