What Are Topic Maps
by Lars Marius Garshol
|
Pages: 1, 2, 3
How topic maps work
By now you are probably wondering how all this works. The answer is surprisingly simple. At the heart of topic maps are topics (these are the circles in the diagram), which represent the things the topic map is about. In a topic map about XML, for example, one might expect to find topics representing 'the XML Recommendation', 'the W3C', and 'Tim Bray'.
The next step is the relationships between the topics, which in topic maps is modeled with associations (the lines between the topics). Associations are typed, which means that we can say that the relationship between the XML Recommendation and the W3C is one we might call 'publishing', while the relationship between the Recommendation and Tim Bray is one of 'authorship'.
Associations have one unusual feature. Each topic involved in the association is said to play a role, which is defined by its role type. So in the 'authorship' association Tim Bray plays the role of 'author' while the XML Recommendation plays the role of 'work'. This means that the statements 'Tim Bray wrote the XML Recommendation' and 'the XML Recommendation was written by Tim Bray' are the same statement in topic maps. It is impossible to say the one without at the same time saying the other, and the association can be traversed in either direction. Associations need not be restricted to two topics. Relationships like 'Tim Bray represents Textuality in the W3C' can be expressed using an association with three roles, and it's no more difficult to express than than simpler associations.
The last main feature of topic maps is what is known as occurrences, which are information resources relevant to a topic. For "Tim Bray", occurrences might be his home page, a portrait, CV, etc. Since occurrences may also be typed, these different kinds of resources can be distinguished. This means that when a user comes to a topic and wants more information about it, the user not only gets a set of links, but also knows what makes each link interesting.
The last point to note is that topics may also have types, and reasonable types for the example topics might be 'standard', 'standards body', and 'person'. Types in topic maps, however, are themselves topics, which means that anyone creating a topic map can choose what topic types, association and role types, and occurrence types they want to use. As a result, the model is infinitely extensible and adaptable and can capture just about any kind of information.
One of the benefits of the topic maps approach is that usually, when you are creating a topic map for a set of existing data (documents or databases), you will find that a number of important concepts are touched on in the dataset, without actually having identities of their own. One example of this might be if you were to topic map the W3C web site. It is a fairly well structured site, but let's say you are looking for information on XML Base. You can easily find the specification, and using the search you can find various pages that mention it. And that's it. With a topic map, on the other hand, you'd have a topic representing 'XML Base', the concept. Going to that topic would present you with information like 'XML Base is an XML vocabulary' (topic type), 'XML Base uses XML namespaces' (association), 'XML Base is used by XHTML' (association), 'the XML Base specification is here' (occurrence), and so on. This makes it easier to find what you are looking for, and also to learn about it once you have found it.
Making a topic map
Before we look at the practicalities, a little background is needed. Topic maps are an ISO standard, published as ISO/IEC 13250 in 2000. That standard defines the basic model and an SGML-based syntax for it, which uses HyTime for linking, and is therefore known as HyTM. When the standard was published it was clear that something more web-optimized was needed, and so an ad-hoc organization known as TopicMaps.Org was formed to create a topic map syntax based on XML and URIs.
TopicMaps.Org published its XML Topic Maps (XTM) 1.0 specification in early 2001, and in October of the same year that syntax was accepted into the second edition of ISO 13250 as an annex. Today, XTM is the main topic map syntax and is supported by nearly all topic map tools. In this article we use XTM as the example syntax.
To create a topic map for the example above we can start by defining topics for the three topic types. This is done as follows:
<topicMap xmlns="http://www.topicmaps.org/xtm/1.0/"
xmlns:xlink="http://www.w3.org/1999/xlink">
<topic id="person">
<baseName>
<baseNameString>Person</baseNameString>
</baseName>
</topic>
<topic id="standards-body">
<baseName>
<baseNameString>Standards body</baseNameString>
</baseName>
</topic>
<topic id="standard">
<baseName>
<baseNameString>Standard</baseNameString>
</baseName>
</topic>
</topicMap>
This gives us three topics suitable for use as topic types in our topic map. The baseName elements give the topics names that can be used to display the topics. The next step is to add one topic to be used as an occurrence type and our three instance topics, complete with names and occurrences. (The fragment below should be inserted inside the topicMap element above. The order of topic elements in topic maps is irrelevant.)
<topic id="xml-rec">
<instanceOf>
<topicRef xlink:href="#standard"/>
</instanceOf>
<baseName>
<baseNameString>The XML Recommendation</baseNameString>
</baseName>
</topic>
<topic id="tim-bray">
<instanceOf>
<topicRef xlink:href="#person"/>
</instanceOf>
<baseName>
<baseNameString>Tim Bray</baseNameString>
</baseName>
</topic>
<topic id="homepage">
<baseName>
<baseNameString>Homepage</baseNameString>
</baseName>
</topic>
<topic id="w3c">
<instanceOf>
<topicRef xlink:href="#standards-body"/>
</instanceOf>
<baseName>
<baseNameString>World Wide Web Consortium</baseNameString>
</baseName>
<occurrence>
<instanceOf>
<topicRef xlink:href="#homepage"/>
</instanceOf>
<resourceRef xlink:href="http://www.w3.org"/>
</occurrence>
</topic>
The first two topic elements create topics for the XML Recommendation and Tim Bray, making them instances of the "standard" and "person" topic types we defined earlier. Notice how instanceOf is used to provide the class and topicRef is used to point to the topic that defines the class. Then we define the occurrence type "homepage" and finally a topic for the W3C, which is of type "standards-body" and even has a "homepage" occurrence. The resourceRef element inside the occurrence gives the URI of the resource that is the occurrence.
Finally, we are ready to create topics for the association and role types and create the corresponding associations in order to complete the topic map. The fragment below does just this.
<topic id="authorship">
<baseName>
<baseNameString>Authorship</baseNameString>
</baseName>
</topic>
<topic id="author">
<baseName>
<baseNameString>Author</baseNameString>
</baseName>
</topic>
<topic id="work">
<baseName>
<baseNameString>Work</baseNameString>
</baseName>
</topic>
<association>
<instanceOf>
<topicRef xlink:href="#authorship"/>
</instanceOf>
<member>
<roleSpec>
<topicRef xlink:href="#author"/>
</roleSpec>
<topicRef xlink:href="#tim-bray"/>
</member>
<member>
<roleSpec>
<topicRef xlink:href="#work"/>
</roleSpec>
<topicRef xlink:href="#xml-rec"/>
</member>
</association>
In order to keep this example at a reasonable length only the first association is provided here. It is of type "authorship" and has one topic playing the role of "author" (Tim Bray) and another playing the role of "work" (the XML Recommendation). The involvement of topics in the association is described using the member element type, and role types are defined with roleSpec. The participating topic is pointed to by the topicRef directly inside the member.
And that's it, really. This is a complete, although trivial, topic map. With a topic map browser you can actually browse through it, do queries on it, and so on. (See the links section at the bottom.) I've made a complete version for your convenience as well.