사용자 복합 유형에서 리플렉션 정보 처리

복합 유형에서 리플렉션 정보를 검색할 수 있습니다.

이 태스크 정보

다음 예제에서는 스키마 하나와 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 ) );
   }
}