Creating a Hierarchy

In order for the HierarchyManager class to recognise a hierarchy, it is necessary to provide a hierarchy topic which defines the hierarchy itself. This hierarchy topic contains associations to:

Two topics are connected to partipicate in a hierarchy in a parent-child relationship iff:

The hierarchy topic and the types of associations used to specify the root topic and the hierarchy association types all use a fixed set of PSIs which are defined by Techquila (see http://www.techquila.com/psi/).

In the model specified by Techquila, each hierarchy must be defined by a topic of type "Facet". This topic represents the entire hierarchy as a whole and so should be given a name that reflects the name of the whole hierarchy. This topic is not the root of the hierarchy - it only acts to define how to find the hierarchy and how to traverse it. The root of the hierarchy is identified using an association of the type "Facet-Has-Root". This association must be a binary association between the topic representing the hierarchy (playing the role "Facet") and the topic which is the root of the hierarchy (playing the role "Facet-Root"). The hierarchy must be constructed as a set of topics all connected together using the same type of association. The type of association used to construct the hierarchy is identified using an association of the type "Facet-Has-Hierarchy-Type". This association must also be a binary association between the topic representing the hierarchy (playing the role "Facet") and the topic which types the associations used to construct the hierarchy (playing the role "Facet-Hierarchy-Type"). Finally, the association roles played by the topics in the hierarchy must be divided into superordinate roles (i.e. the role played by the "parent" in the hierarchy) and subordinate roles (the role played by the "child" in the hierarchy). This is done by creating associations of type "Facet-Has-Superordinate-Role-Type" and "Facet-Has-Subordinate-Role-Type" between the facet topic and the topics defining the parent role type and child role type respectively.

All of the types described above have a Published Subject Identifier (PSI) defined for them by Techquila and summarised in the table below. If you follow the PSI URL you will be taken to pages which provide the official Techquila description for each of these topics.

Table 8.1. Topic PSIs for Topic Hierarchies

TopicPSI
Facet http://www.techquila.com/psi/faceted-classification/#facet
Facet-Has-Hierarchy-Type http://www.techquila.com/psi/faceted-classification/#facet-has-hierarchy-type
Facet-Hierarchy-Type http://www.techquila.com/psi/faceted-classification/#facet-hierarchy-type
Facet-Has-Root http://www.techquila.com/psi/faceted-classification/#facet-has-root
Facet-Root http://www.techquila.com/psi/faceted-classification/#facet-root
Facet-Has-Subordinate-Role-Typehttp://www.techquila.com/psi/faceted-classification/#facet-has-subordinate-role-type
Subordinate-Role-Type http://www.techquila.com/psi/hierarchy/#subordinate-role-type
Facet-Has-Superordinate-Role-Typehttp://www.techquila.com/psi/faceted-classification/#facet-has-superordinate-role-type
Superordinate-Role-Type http://www.techquila.com/psi/hierarchy/#superordinate-role-type

The diagram below shows this model in a schematic form.

Figure 8.1. Defining A Hierarchy Model

Defining A Hierarchy Model

Although this may seem a little complex from the description above, it is actually very straightforward. The following procedure takes you through the process of defining a new hierarchy in an XTM topic map step by step.

Procedure 8.1. Creating a Topic Hierarchy

  1. Create Or Import Techquila PSIs

    This step only has to be performed once for each topic map and can be skipped by using subjectIndicatorRef rather than topicRef elements to refer to the Techquila topics. This can also be done through the TMCore Topic Map Editor web application or by invoking the static CreateHierarchySchemaTopics(ITopicMap) method on the NetworkedPlanet.TMCore.Utils.HierarchyManager class.

  2. Create The Hierarchy Facet

    This is the topic which defines the hierarchy as a whole. This topic must be an instance of the Techquila topic "Facet". In XTM this can be achieved as follows:

    <topic id="places">
      <instanceOf>
        <subjectIndicatorRef xlink:href="http://www.techquila.com/psi/faceted-classification/#facet"/>
      </instanceOf>
      <baseName>
        <baseNameString>Places</baseNameString>
      </baseName>
      <!-- Any other topic data -->
    </topic>

    Note

    The baseName elements shown in this and all following examples are illustrative only - they are not required in constructing your hierarchy.

  3. Create The Hierarchy Root

    This is the topic that will be at the root of the hierarchy. Hierarchies can only have a single root topic. The root topic can be of any type (or types) you like. For example:

    <topic id="the-world">
      <instanceOf><topicRef xlink:href="planet"/></instanceOf>
      <baseName>
        <baseNameString>The World</baseNameString>
      </baseName>
    </topic>

    To identify this topic as the hierarchy root, you must create a "Facet-Has-Root" association between the facet topic created in step 2 and this root topic:

    <!-- The root of the "Places" hierarchy is "The World" -->
    <association>
      <instanceOf>
        <subjectIndicatorRef 
          xlink:href="http://www.techquila.com/psi/faceted-classification/#facet-has-root"/>
      </instanceOf>
      <member>
        <roleSpec>
          <subjectIndicatorRef
            xlink:href="http://www.techquila.com/psi/faceted-classification/#facet"/>
        </roleSpec>
        <topicRef xlink:href="#places"/>
      </member>
      <member>
        <roleSpec>
          <subjectIndicatorRef
            xlink:href="http://www.techquila.com/psi/faceted-classification/#facet-root"/>
        </roleSpec>
        <topicRef xlink:href="#the-world"/>
      </member>
    </association>
    
  4. Specify The Hierarchy Association Type

    All topics in our hierarchy must be associated with one another using a single type of association. The topic for that association type must be identified using a "Facet-Has-Hierarchy-Type" association between the facet topic created in step 2 and the association typing topic. For example:

    <topic id="contains">
      <baseName>
        <baseNameString>Contains</baseNameString>
      </baseName>
    </topic>
    
    <!-- The hierarchy association for "Places" hierarchy is "Contains" -->
    <association>
      <instanceOf>
        <subjectIndicatorRef 
          xlink:href="http://www.techquila.com/psi/faceted-classification/#facet-has-hierarchy-type"/>
      </instanceOf>
      <member>
        <roleSpec>
          <subjectIndicatorRef
            xlink:href="http://www.techquila.com/psi/faceted-classification/#facet"/>
        </roleSpec>
        <topicRef xlink:href="#places"/>
      </member>
      <member>
        <roleSpec>
          <subjectIndicatorRef
            xlink:href="http://www.techquila.com/psi/faceted-classification/#facet-hierarchy-type"/>
        </roleSpec>
        <topicRef xlink:href="#contains"/>
      </member>
    </association>
  5. Specify the Subordinate and Superordinate Roles

    The subordinate role is the role played by the child in a hierarchy association; the superordinate role is the role played by the parent. These are identified by creating additional associations between the topic that defines the hierarchy and the topics that define the subordinate and superordinate role types. So for our "Contains" association type, we have the role types "Container" (the superordinate role type) and "Containee" (the subordinate role type):

    <!-- Container role is a superordinate role type -->
    <topic id="container">
      <baseName>
        <baseNameString>Container</baseNameString>
      </baseName>
    </topic>
    
    <association>
      <instanceOf>
        <subjectIndicatorRef
          xlink:href="http://www.techquila.com/psi/faceted-classification/#facet-has-superordinate-role-type"/>
      </instanceOf>
      <member>
        <roleSpec>
          <subjectIndicatorRef xlink:href="http://www.techquila.com/psi/faceted-classification/#facet"/>
        </roleSpec>
        <topicRef xlink:href="#places"/>
      </member>
      <member>
        <roleSpec>
          <subjectIndicatorRef
            xlink:href="http://www.techquila.com/psi/hierarchy/#superordinate-role-type"/>
        </roleSpec>
        <topicRef xlink:href="#container"/>
      </member>
    </association>
    
    <!-- Containee role is a subordinate role type -->
    <topic id="containee">
      <baseName>
        <baseNameString>Containee</baseNameString>
      </baseName>
    </topic>
    
    <association>
      <instanceOf>
        <subjectIndicatorRef
          xlink:href="http://www.techquila.com/psi/faceted-classification/#facet-has-subordinate-role-type"/>
      </instanceOf>
      <member>
        <roleSpec>
          <subjectIndicatorRef xlink:href="http://www.techquila.com/psi/faceted-classification/#facet"/>
        </roleSpec>
        <topicRef xlink:href="#places"/>
      </member>
      <member>
        <roleSpec>
          <subjectIndicatorRef
            xlink:href="http://www.techquila.com/psi/hierarchy/#subordinate-role-type"/>
        </roleSpec>
        <topicRef xlink:href="#containee"/>
      </member>
    </association>
  6. Create Hierarchy Associations

    Now create as many hierarchy associations as necessary. When specifiying all the children of a single topic in the hierarchy you can use either one association with multiple subordinate role players or multiple binary associations. Note that these associations are completely free of the supporting topic infrastructure used to create the hierarchy. This means that any other topic map application that is not aware of the significance of the Techquila PSIs will still present the container/containee relationships as intended.

    <!-- The World contains Europe -->
    <association>
      <instanceOf><topicRef xlink:href="#contains"/></instanceOf>
      <member>
        <roleSpec><topicRef xlink:href="#container"/></instanceOf>
        <topicRef xlink:href="#the-world"/>
      </member>
      <member>
        <roleSpec><topicRef xlink:href="#containee"/></instanceOf>
        <topicRef xlink:href="#europe"/>
      </member>
    </association>
    
    <!-- Europe contains UK and France -->
    <association>
      <instanceOf><topicRef xlink:href="#contains"/></instanceOf>
      <member>
        <roleSpec><topicRef xlink:href="#container"/></instanceOf>
        <topicRef xlink:href="#europe"/>
      </member>
      <member>
        <roleSpec><topicRef xlink:href="#containee"/></instanceOf>
        <topicRef xlink:href="#uk"/>
        <topicRef xlink:href="#france"/>
      </member>
    </association>