9.2.3 Semantics representations and primitives
In oneM2M the <semanticDescriptor> resource is used to provide semantic annotations, such as the ones in clause 7. Semantic annotations can use the oneM2M base ontology as well as external ontologies, such as SAREF. The oneM2M base ontology is primarily used to discover how to use the APIs for devices that are modelled in oneM2M. External Ontologies are used to describe the capabilities of the device being models or other features of data that is available in oneM2M, i.e., ontologies could describe the content of data or metadata. A <semanticDescriptor> resource can be a child of <AE>, <container>, <contentInstance>, <group>, <node>, <flexContainer>, <timeSeries>, <mgmtObj> resources.
The semantic annotations in a <semanticDescription> can apply to the parent resource or other resources. There are two types of semantic searches that can be performed; 1) semantic discovery and 2) semantic query. A semantic discovery will find matching <semanticDescriptor> resources and provide the URI of the parent resource of the <semanticDescriptor> resources that match the query. A semantic query request will return the response to the SPARQL query in the format defined in the query. These differences may impact the decision regarding what parent resource to target for a <semanticDescriptor> resource.
The representation of a <semanticDescriptor> resource must be in one of the supported semantic formats supported in oneM2M. The supported formats from TS-0004 are:
Figure 12: <semanticDescriptor> Resource
In this use case we use RDF/XML in the primitives as that is supported by the test implementation. The semantic annotations shown in clause 7 are written in RDF/Turtle. A convenient utility to convert the RDF/Turtle is available at https://www.easyrdf.org/converter or the python rdflib library.
Another requirement for the <semanticDescriptor> resource is that the descriptor attribute is set to the value of the semantic triples encoded as xs:base64Binary.
And finally, when issuing a Semantic request, whether it is a discovery or query, the semanticFilter parameter of the request requires "percent-encoding" when using the HTTP protocol binding, as used in this guide.
Since the <semanticDescriptor> resource is separate from the resources that it describes there is considerable flexibility available to application developers. For example, if a product such as an IPE for a clothes washing machine does not provide <semanticDescriptor> resources, it is possible for another application to provide the <semanticDescriptor> resources. This can support application development that continually expands its supported devices. In this clothes washing machine use case the client application can deploy with any of the three models described above, but as the application developer becomes aware of other clothes washing machines, they can create the <semanticDescriptor> resources for those devices and then applications that have been developed to use the original deployed devices will be interoperable with these new devices, without change to the application. This concept is one of the ways that oneM2M breaks down the silos of vertical deployments.