Skip to main content
Jump to: navigation, search

JET FAQ How do I test for the type/EClass of an element in XPath?

To test for a subclass, use the self::Subclass test. See the sceanrio below. The following Ecore relationships exits

  • SuperClass <- SubClass1
  • SuperClass <- SubClass2
  • SuperClass <- Banana

bananas are caught in the otherwise clause.

<c:iterate select="$container/referenceOfTypeSuperClass" var="superClassInstance">


<c:when test="$superClassInstance/self::SubClass1">
This is an instance of type SubClass1!

<c:when test="$superClassInstance/self::SubClass2">
This is an instance of type SubClass2!

This is an instance of SuperClass, or any other Subclass of it!



Back to the top