Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

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

Revision as of 20:54, 6 November 2007 by Jgsuess.gmail.com (Talk | contribs) (New page: To test for a subclass, use the ''self::Subclass'' test. See the sceanrio below. The following Ecore relationships exits * SuperClass <- SubClass1 * SuperClass <- SubClass2 * SuperClass <...)

(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:choose>

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

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

<c:otherwise>
This is an instance of SuperClass, or any other Subclass of it!
</c:otherwise>

</c:choose>

</c:iterate>

Copyright © Eclipse Foundation, Inc. All Rights Reserved.