Preamble¶
What’s in this document?
The preamble (introductory SOML section) includes metadata and prefixes.
Schema Metadata¶
You can provide some info (metadata) about the schema.
id: /soml/some-domain
label: Some Domain schema
created: 2019-04-15
updated: 2019-05-10
creator: http://ontotext.com
versionInfo: 1.0
Only id is mandatory, the other fields are optional.
idis used for SOML operations (create, update, delete) by the SOaaS services. It should start with/soml/versionInfois the version of the schema (SOML instance and corresponding ontology), not a version of the SOML language
The rest of the preamble defines prefixes (namespaces) that are used to map object and prop names to IRIs (URLs) as used in RDF.
Special Prefixes¶
specialPrefixes:
base_iri: http://example.org/resource/
vocab_iri: http://example.org/vocabulary/
vocab_prefix: voc
ontology_iri: http://example.org/vocabulary
shape_iri: http://example.org/shape/
The special prefixes (namespaces) include:
base_iri: base IRI for data (resources), used in SOML characteristics such astypeandprefix. We currently use full IRIs in GraphQL queries and responses, but in the future may shorten them using the base (see Naming Convention and IRI Processing).vocab_iri: default namespace for vocabulary (ontology) terms, i.e. object and prop names. SOML allows the use of multiple ontologies (see Prefixes) through underscore prefixes likepfx_prop, and one of them is designated as default so it can be used without prefix.vocab_prefix: prefix corresponding to the vocab IRI.It must be used in SOML for prop names that conflict with a reserved word (see Reserved Words)
It is also useful in languages that don’t have such a concept (eg Turtle), as we don’t like to use an empty prefix
The following IRIs may be used in the future:
ontology_iri: RDF Ontology IRI, used to make statements about the ontology. Typically it’s the same as the vocab IRI but without a trailing slash or hash.shapes_iri: RDF Shapes IRI: all generated shapes live under this IRI
Predefined Prefixes¶
SOML predefines a few commonly used prefixes such as dct: gn: owl: rdf: xsd:, and some more exotic prefixes:
puml:: used by the rdfpuml diagramming toolso:: in the future may transmit in JSONLD built-in SOML props likeso:nameandso:typeres:: in the future may transmit in JSONLD dynamic props calculated in queries
prefixes:
# common prefixes
so: http://www.ontotext.com/semantic-object/
res: http://www.ontotext.com/semantic-object/result/
dct: http://purl.org/dc/terms/
gn: http://www.geonames.org/ontology#
owl: http://www.w3.org/2002/07/owl#
puml: http://plantuml.com/ontology#
rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
rdfs: http://www.w3.org/2000/01/rdf-schema#
skos: http://www.w3.org/2004/02/skos/core#
void: http://rdfs.org/ns/void#
wgs84: http://www.w3.org/2003/01/geo/wgs84_pos#
xsd: http://www.w3.org/2001/XMLSchema#
The Special Prefixes shown in the previous section and the prefixes shown above are predefined and may be used without having to define them (but can be overridden): This means that a valid SOML doesn’t need to define any prefixes.
A plain name like
Objorpropis mapped usingvocab_iri, which by using the predefined prefixes maps tovoc:Objorvoc:proprespectively, and thus tohttp://example.org/vocabulary/IRIs.Of course, in a real application you’d want to define your own special prefixes.
Prefixes¶
You can also define your own prefixes for your domain, eg:
prefixes:
# schema-specific prefixes
sw: https://swapi.co/vocabulary/
dbr: http://dbpedia.org/resource/
dbo: http://dbpedia.org/ontology/
Rules:
Each prefix should conform to the Turtle grammar production PN_PREFIX
Prefixes should not mask defined IRI schemes such as
http: https: mailto: ftp: mailto: urn: geo:. (In some cases you may want to break this guideline for convenience, eg the schema.org JSON-LD context defines a prefixgeo:that breaks it)
Naming Convention and IRI Processing¶
Class and property names (the YAML key) play several important roles:
They are used in SOML to describe objects, properties and the connection between them.
They (together with
prefixesandvocab_iriare used to derive RDF IRIs).They are used in GraphQL as type and field names.
pfx:nameis translated topfx_nameto make it GraphQL and JSON friendly
If a name includes :, the part before it must be a defined prefix (see Prefixes).
The local parts of property and class names (part after : if any) must comply with the following naming conventions:
Prop names must start with a lowercase Unicode letter, and are recommended to follow a
lowerCamelCaseconvention.Class names must start with an uppercase Unicode letter, and are recommended to follow an
UpperCamelCase(also calledPascalCase) convention.Both must conform to the Turtle grammar production PN_PREFIX. Please note that this is stricter than RDF and Turtle local name conventions.
In particular they cannot use punctuation chars such as
:.-. If you need to use names that don’t conform to this (eg classAuto.Modelor propsbirth-dateorbirth.date), use the class characteristictypeor prop characteristicrdfProp. (You can also use them to map a user-friendly SOML name to a less readable RDF name in an underlying ontology.)Cannot start with two underscores
__, which is reserved for GraphQL introspection.If they include an underscore, they cannot start with
pfx_wherepfx:is a defined prefix. Usepfx:nameif you meant that prefix, orvoc:pfx_nameif you meant the default vocab namespace (see Special Prefixes)Cannot be a reserved word, see Reserved Words.
Names in SOML are converted to IRIs as follows:
If the prop has characteristic
rdfProp, use that instead of the name.If a name starts with a defined prefix
pfx:, replace the prefix with the coresponding IRI.Otherwise prepend
vocab_iri.
Strings in the type and rdfProp characteristics are converted to IRIs as follows:
If the string starts with a defined IRI scheme, use it directly (absolute IRI).
Else if the string starts with a defined prefix
pfx:, replace the prefix with the coresponding IRI (prefixed IRI).Else if the string includes only Unicode alphanumerics and
[-._], prependvocab_iri(relative ontology IRI).Else prepend
base_iri(relative instance IRI). Typically such string will include/or#and is used in thetypecharacteristic to designate a “business type” not defined in an ontology, eg askos:ConceptSchemeIRI.
GraphQL queries and JSON responses use absolute IRIs for iri fields. This includes:
the
idfield of every object, which is its IRIfields of type
iri(egwebsiteUrlof a company) that reference external resourcesthe
typefield, which is the datatype of Literals orrdf:typeof objects (most of the time you don’t need to specify these explicitly)
We have an idea to use Compact URIs (CURIEs) in the future to shorten GraphQL queries and JSON responses (see CURIE in Wikipedia and the CURIE W3C TR) but have not yet done so because this may cause confusion in some cases. If you’d like to use CURIEs, please send us feedback.
Reserved Words¶
The following reserved words cannot be used as prop names: id type lang value name:
idis the node IRI and is a mandatory field for every object (the GraphQL typeID!is used)typeis therdf:typeof objects or datatype of scalarslangis the language tag of a Literal or langStringvalueis the value of a Literalnameis a uniform preferred name for an object
The following reserved words cannot be used as object names: Literal Object Nameable
Literaltogether withlang,typeandvalueis used to represent an RDF literalObjectis an interface for common functionality: the presence ofidandtypeNameableis an interface used for the presence ofname
To use such prop/object names in the vocab namespace, you need to spell them in full, eg voc:type voc:name voc:Object.
GraphQL descr Directive¶
Objects and properties have label and descr.
These are emitted separately in GraphQL, so they can be used more conveniently in a UI app.
Label comes before the object/prop as a “string”: that is a standard GraphQL feature.
Descr comes after the object/prop as a
@descrdirective.
For example, this SOML property:
prefName: {label: "Preferred name", min: 1, descr: "A single selected name"}
Is emitted in GraphQL as follows:
"Preferred name"
prefName: String! @descr(_:"A single selected name")
The directive is defined as follows:
directive @descr(_:String!) on FIELD_DEFINITION | OBJECT | INTERFACE
According to the GraphQL spec,
directive values are not returned as part of GraphQL schema introspection.
This problem is discussed in issue graphql-spec#300
and we added @descr as a use case, and return the directive value anyway.