Jump to: navigation, search

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

Revision as of 19:54, 6 November 2007 by Jgsuess.itee.uq.edu.au (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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!