Semantic Definition Format (SDF) for Data and Interactions of Things: Compact Notation
Universität Bremen TZI
Postfach 330440
Bremen
D-28359
Germany
+49-421-218-63921
cabo@tzi.org
Applications
T2TRG
Internet-Draft
The Semantic Definition Format (SDF) is a format for domain experts to
use in the creation and maintenance of data and interaction models in
the Internet of Things. It was created as a common language for use
in the development of the One Data Model liaison organization (OneDM)
definitions. Tools convert this format to database formats and other
serializations as needed.
The SDF format is mainly intended for interchange between machine
generation and machine processing. However, there often is a need for
humans to look at and edit SDF models.
Similar to the way Relax-NG as defined in ISO/IEC 19757-2 has an XML
format and a compact format (Annex C), this specification defines a
compact format to go along SDF's JSON format.
The present version of this document is mostly a proof of concept, but
was deemed useful to obtain initial feedback on the approach taken.
Contributing
Recent versions of this document are available at its GitHub
repository https://github.com/cabo/sdfc -- this also provides
an issue tracker as well as a way to supply "pull requests".
General discussion of this SDF Internet-Draft happens on the mailing
list of the IETF ASDF Working Group, asdf@ietf.org (subscribe at
https://www.ietf.org/mailman/listinfo/asdf).
The IETF Note Well applies (https://www.ietf.org/about/note-well/).
Introduction
(See Abstract for now.)
The intention is to be able to bidirectionally translate between
compact and JSON form, without appreciable semantic losses. This will
allow viewing SDF in compact form, apply edits if needed, and then
continuing processing it in JSON form. As a limitation of this
approach, it will be difficult to always recreate the order of map
entries (members of JSON objects) in the JSON form; this order is
essentially arbitrary as maps (JSON objects) in JSON are unordered.
(In the long run, it may be useful to define a canonical order in the
SDF specification or here.)
An initial prototype of a converter from compact form to JSON form was
constructed during the ASDF/WISHI hackathon preceding IETF110.
A more complete, bidirectionally operating version of this tool is
planned for release in week 12 of 2021.
Overview
The SDF compact format is a YAML file ; a good part of the work
needed for a compact representation is already done by the increased
user-friendliness of YAML over JSON.
In addition, all the sections defined with named<...> in the CDDL
definition of SDF have been compacted into map entries with
space-separated keys, giving the kind first and the name next.
This saves the need for another level of hierarchy and reminds the
reader of the kind of item being specified.
The map key description is replaced by :, which also is rendered
in the most compact form possible in YAML.
The dataqualities readable, writable, and observable, together with
optionality, are compressed into a four-character map key: The first
three are translated into rwo when set (default in SDF) and into
--- when not set. The fourth character is ? for optional and !
for required.
The value of this abbreviated key is a CDDL rendition of the
attributes defined in the jsonschema production in . To further reduce noise, a top-level array
production in the CDDL can be represented as an array in the YAML
(i.e., does not require additional quotes).
Example Definition
This is an SDF-compact version of a slightly modified copy of the
sdfobject-cadence.sdf.json model found at the time of writing in
OneDM's SDF playground.
(This example was chosen more or less randomly; better examples can
probably be found. The modification is the addition of a unit quality.)
info:
copyright: Copyright 2018-2019 Open Connectivity Foundation, Inc. All rights reserved.
version: '2019-06-11'
title: Cadence
license: https://github.com/one-data-model/oneDM/blob/master/LICENSE
object cadence:
:: This Resource describes the cadence, which is the number of
revolutions of crank per minute when cyclists pedal the
pedals. The unit, which is the default unit, is rpm. The cadence
Property is a read-only value that is provided by the
server. When range (from "oic. r. baseresource") is omitted the
default is 0 to +MAXFLOAT.
property cadence:
r-o!: integer .ge 0
unit: 1/min
:: This Property describes the rate at which a cyclist is pedalling/turning
the pedals.
property range:
r-o?: [2*2 integer]
:: The valid range for the Property in the Resource as an integer.
The first value in the array is the minimum value, the second value in the
array is the maximum value.
property step:
r-o?: integer
:: Step value across the defined range when the range is an integer. This
is the increment for valid values across the range; so if range is 0..10
and step is 2 then valid values are 0,2,4,6,8,10.
The result of automatically converting this YAML file using the
prototype sdfc tool back into the JSON form of SDF is given in
.
Except for the unit addition, it is semantically identical to the
sdfobject-cadence.sdf.json.
Differences are visible in the order of map entries (members in JSON
objects); a future version of the sdfc tool could attempt to
preserve more of this order, even though it does not carry semantics.
References
Normative References
Concise Data Definition Language (CDDL): A Notational Convention to Express Concise Binary Object Representation (CBOR) and JSON Data Structures
This document proposes a notational convention to express Concise Binary Object Representation (CBOR) data structures (RFC 7049). Its main goal is to provide an easy and unambiguous way to express structures for protocol messages and data formats that use CBOR or JSON.
Semantic Definition Format (SDF) for Data and Interactions of Things
Dogtiger Labs
Universität Bremen TZI
The Semantic Definition Format (SDF) is a format for domain experts
to use in the creation and maintenance of data and interaction models
in the Internet of Things. It was created as a common language for
use in the development of the One Data Model liaison organization
(OneDM) definitions. Tools convert this format to database formats
and other serializations as needed.
An SDF specification describes definitions of SDF Objects and their
associated interactions (Events, Actions, Properties), as well as the
Data types for the information exchanged in those interactions.
A JSON format representation of SDF 1.0 was defined in the previous
(-00) version of this document. SDF 1.1 is expected to be defined in
a future version; the present document is a _candidate implementation
draft_ for SDF 1.1. If the ASDF WG reaches consensus on this
candidate, the next version will be SDF 1.1, an SDF implementation
draft.
Informative References
YAML Ain't Markup Language (YAML[TM]) Version 1.2
Information technology — Document Schema Definition Language (DSDL) — Part 2: Regular-grammar-based validation — RELAX NG
ISO/IEC
Example in SDF JSON format
{
"info": {
"title": "Cadence",
"license": "https://github.com/one-data-model/oneDM/blob/master/LICENSE",
"version": "2019-06-11",
"copyright": "Copyright 2018-2019 Open Connectivity Foundation, Inc. All rights reserved."
},
"sdfObject": {
"cadence": {
"description": "This Resource describes the cadence, which is the number of revolutions of crank per minute when cyclists pedal the pedals. The unit, which is the default unit, is rpm. The cadence Property is a read-only value that is provided by the server. When range (from \"oic. r. baseresource\") is omitted the default is 0 to +MAXFLOAT.",
"sdfProperty": {
"step": {
"type": "integer",
"writable": false,
"description": "Step value across the defined range when the range is an integer. This is the increment for valid values across the range; so if range is 0..10 and step is 2 then valid values are 0,2,4,6,8,10."
},
"range": {
"type": "array",
"items": {
"type": "integer"
},
"maxItems": 2,
"minItems": 2,
"writable": false,
"description": "The valid range for the Property in the Resource as an integer. The first value in the array is the minimum value, the second value in the array is the maximum value."
},
"cadence": {
"type": "integer",
"minimum": 0,
"writable": false,
"description": "This Property describes the rate at which a cyclist is pedalling/turning the pedals."
}
},
"sdfRequired": [
"#/sdfObject/cadence/sdfProperty/cadence"
]
}
}
}
Acknowledgements
The idea for this draft originated at the IETF110 ASDF/WISHI hackathon.
The author would like to thank the attendees for initial feedback.