-
Notifications
You must be signed in to change notification settings - Fork 0
Design
The main goal of this small vocabulary is for describing the mapping between declarative object instantiations in the object-oriented components vocabulary and JavaScript/JSON objects, so that it can be used in a semantic dependency injection framework to instantiate objects, such as Components.js.
The main requirement was that it should be able to describe JavaScript/JSON values objects. We designed the vocabulary in such a way that it can also be used for other object-oriented programming languages.
Requirements:
- Define an object with fields and values
- Define an array with values
- Values can either be literals, or they can refer to other mappable entries
This vocabulary was created in conjunction with the development of Components.js.
We first defined om:ObjectMapping
as a root mapping type, which is responsible for linking with all the mapping properties. Similarly, om:ArrayMapping
is defined as a subtype to indicate the object being an array, just like in JavaScript.
A om:ObjectMapping
can have multiple om:field
properties, which has as range a om:ObjectMappingEntry
.
This entry has a om:fieldName
and a value (either om:fieldValue
or om:fieldValueRaw
). The name identifies the final object field name, and the value indicates the final field value. If om:fieldValueRaw
is used, then the literal value will be converted to a runtime value as-is. Otherwise, if om:fieldValue
is used, then the referred value is the predicate of a class that can be bound to a certain value during instantiation, as defined by the Object-Oriented vocabulary. If this value is again a om:ObjectMapping
, then the mapping will happen recursively.
Similarly, om:ArrayMapping
can have an list of om:ArrayMappingElements
, where each element can only have a value (either om:fieldValue
or om:fieldValueRaw
), without a name. This is then converted to a runtime JavaScript array.
Practical example can be found at http://componentsjs.readthedocs.io/en/latest/configuration/components/object_mapping/