EDXML Ontology Bricks

EDXML ontology bricks are commonly used to share object types and concepts. The EDXML Foundation keeps an online repository of shared definitions.

Bricks can be registered with the Ontology class. After registering a brick, you can create an event type and refer to the object types and concepts from the brick. The ontology will automatically fetch the referred ontology elements from the registered brick and include them in the ontology. The following example illustrates this:

from edxml.ontology import Brick, Ontology


# Define an ontology brick
class MyBrick(Brick):
    @classmethod
    def generate_object_types(cls, target_ontology):
        yield target_ontology.create_object_type('my.object.type')


# Register brick with Ontology class
Ontology.register_brick(MyBrick)

# Now we can refer to the object type in the brick
ontology = Ontology()
event_type = ontology.create_event_type('my.event.type')
event_type.create_property('prop', object_type_name='my.object.type')

edxml.ontology.Brick

class edxml.ontology.Brick

Bases: object

Class representing an ontology brick. Ontology bricks contain definitions of object types and concepts. By defining these in ontology bricks, the definitions can be shared and installed using standard Python package management tools.

Using ontology bricks simplifies the process of producing and maintaining collections of tools that generate mutually compatible EDXML data streams, by sharing ontology element definitions in the form of Python modules.

Ontology bricks should extend this class and override the generate methods that create the ontology elements.

classmethod generate_object_types(target_ontology)

Creates any object types that are defined by the brick using specified ontology, yielding each of the created ObjectType instances.

Parameters:target_ontology (edxml.ontology.Ontology) – The ontology to add to
Yields:List[edxml.ontology.ObjectType]
classmethod generate_concepts(target_ontology)

Creates any concepts that are defined by the brick using specified ontology, yielding each of the created Concept instances.

Parameters:target_ontology (edxml.ontology.Ontology) – The ontology to add to
Yields:List[edxml.ontology.Concept]
classmethod test()

This method can be used in unit tests to verify ontology bricks.