Question & Answer
Question
How to retrieve attributes inherited from the base class using a IBM Rhapsody project and IBM Publishing Document Studio
Author: Chris Sutton
Cause
The model used in this example consists of two classes. The parent class has an attribute. The child class is inheriting the attribute from the parent class.
![image 8156](/support/pages/system/files/inline-images/image_8156.png)
Answer
You can access the generalizations for each class inheritance and traverse the metamodel to the attributes of the base class.
However, the Rhapsody metamodel provides a Base node that can be used as a shortcut to access the base class directly from the child class.
The metaclass of the node under Base is of type Classifier. This is too generic and does not allow access to the typical data contained under a class. Therefore, you must cast the Classifier node to a Class node. This is highlighted in the screenshot below.
![image 8155](/support/pages/system/files/inline-images/image_8155.png)
More information on using casting in IBM Publishing Document Studio can be found here:
Now that the Classifier node is recast to the correct type it can be used in query $25 and the attribute node can be used in query $27.
The output shows all classes, all nested base classes and all nested attributes within those base classes:
![image 8157](/support/pages/system/files/inline-images/image_8157.png)
[{"Line of Business":{"code":"LOB59","label":"Sustainability Software"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSB2MU","label":"IBM Engineering Systems Design Rhapsody"},"ARM Category":[{"code":"a8m50000000CjSOAA0","label":"Rhapsody->Collaborations->Rational Publishing Engine"}],"ARM Case Number":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Version(s)"}]
Was this topic helpful?
Document Information
Modified date:
27 May 2022
UID
ibm16411225