Note
ZTM Topic Maps has other packages that are better suited to describe and modify the ontology, particularly ztm.ontology. This page documents what is provided by ztm.topicmaps itself.
While not a perfect definition, in most topic maps the ontology is essentially made up of the topics that types of other items.
Since the types are also topics the ontology is part of the topic map itself. This allows quite a bit of descriptive flexibility in your designs and means that it can be manipulated using the same methods as any other topic.
Topics that act as a type for another topic gets marked with the ITopicType interface:
>>> import ztm.topicmaps
>>> topicmap = ztm.topicmaps.topicmap.TopicMap()
>>> topictype = topicmap.createTopic()
>>> ztm.topicmaps.interfaces.ITopicType.providedBy(topictype)
False
>>> instance = topicmap.createTopic()
>>> topictype.addInstance(instance)
>>> ztm.topicmaps.interfaces.ITopicType.providedBy(topictype)
True
The ITopicType interface is removed when there are no more types.
>>> instance.removeType(topictype)
>>> ztm.topicmaps.interfaces.ITopicType.providedBy(topictype)
False
Similarly there are marker interfaces for name-, occurence-, association- and role-types.
>>> nametype = topicmap.createTopic()
>>> ztm.topicmaps.interfaces.INameType.providedBy(nametype)
False
>>> name = instance.createName('test', nametype)
>>> ztm.topicmaps.interfaces.INameType.providedBy(nametype)
True
>>> name.delete()
>>> ztm.topicmaps.interfaces.INameType.providedBy(nametype)
False
You can find sets with the types on the topic map.
>>> topicmap.associationtypes
frozenset([])
>>> name = instance.createName('test', nametype)
>>> nametype in topicmap.nametypes
True
Note
This functionality is likely to be moved to ztm.ontology before version 1.0.
If you read the interface definitions of ztm.topicmaps you may come across some interfaces called IPossibleTopicType and similar for other information items.
These interfaces are used to mark topics that do not yet have topic or item instances but that you would like to make part of the ontology.
They are mostly used while building the initial ontology.