ユーザー複合タイプに関するリフレクション情報の処理
複合タイプに関するリフレクション情報を取得することができます。
このタスクについて
以下の例は、スキーマと 2 つのルール (displayCollectionAttribute および displayIntXmlElement) を含んでおり、複合タイプに関するリフレクション情報を処理する方法を示しています。
手順
ユーザー複合タイプに関するリフレクション情報を処理する手順は、以下のとおりです。
以下のスキーマを使用します。
<complexType name="person"/>
<sequence>
<element name="name"/>
<element name="surname" maxOccurs="4"/>
<element name="age" type="int"/>
</sequence>
</complexType>
以下に規則を示します。
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 ) );
}
}