MicroStrategy ONE

Block Inheritance

Let's consider the following blocks that are used to display information about the contents of a MicroStrategy folder.

Copy
<block name="Report">
  <definition>
    <property name="dssid" type="String" />
    <property name="dsstp" type="Integer" />
    <property name="dssname" type="String" />
    <property name="numRows" type="Integer" />
    <property name="numCols" type="Integer" />
  </definition>
</block>
<block name="Document">
<definition>
    <property name="dssid" type="String" />
    <property name="dsstp" type="Integer" />
    <property name="dssname" type="String" />
    <property name="numDatasets" type="Integer" />
  </definition>
</block>

The two new blocks, Report and Document, have some properties ("dssid", "dsstp" and "dssname") that are common to each other as well as to the block Object we discussed in Block Library. The "Report" block adds a few more properties, "numRows" and "numCols" while the "Document" block defines its own additional property.

However, instead of duplicating the common properties for the blocks, Report and Document, you can use Block Inheritance to inherit these properties from block Object. The Block Library XML provides an optional inherits attribute whose value is a comma-separated list of Block names.

Thus, the two blocks, Report and Document, can be declared as follows.

Copy
<block name="Report" inherits="Object">
  <definition>
    <property name="numRows" type="Integer" />
    <property name="numCols" type="Integer" />
  </definition>
</block>
<block name="Document" inherits="Object">
<definition>
    <property name="numDatasets" type="Integer" />
  </definition>
</block>

Thus, a block can inherit from any number of "parent" blocks since the optional inherits attribute can take a comma-separated list of Block names. Each parent includes its properties into the child in the order specified by the inherits attribute.

Here are some rules to remember for Block Inheritance:

  1. It is illegal to import a named block property more than once if their types are different. Consider that block C defines a property named "p1" (of type String) and block D defines a property also named "p1" (of type Integer). It is illegal for a block to inherit from both C and D since there are two different definitions for the property named "p1".  

  2. It is not illegal to import multiple definitions of the same property if it has the same type since subsequent definitions are ignored. Consider that block C defines a property named "p1" (of type String) and block D defines a property also named "p1" (also of type String). It is not illegal for a block to inherit from both C and D since the property "p1" has the same type. It is important to note that any subsequent definitions will be ignored.  

  3. To inherit from a base block, that block must already be defined. It is illegal to "forward reference" a block that is not yet defined.