Skip to content

Project contexts

"@context":
  schema: https://schema.org/
  dbo: http://dbpedia.org/ontology/
  dbp: http://dbpedia.org/property/
  dbr: http://dbpedia.org/resource/
  xsd: http://www.w3.org/2001/XMLSchema#
  name: schema:name
  description: schema:description
  subjectOf:
    "@id": schema:subjectOf
    "@type": "@id"
  constellation:
    "@id": dbo:constellation
    "@type": "@id"
  discovered:
    "@id": dbp:discovered
    "@type": xsd:date
  star:
    "@id": dbp:star
    "@type": "@id"
"@context": context.yamlld
$id: dbr:Alpha_Centauri
$type: dbo:Star
name: Alpha Centauri
description: >-
  The closest star system to the Solar System.
constellation: dbr:Centaurus

Relative @context paths resolve from the source's directory. @import may name another relative context. Every path must stay under the served directory. Context files load as source graphs. Changing one reloads its dependents.

Remote URLs: vitrify.

Self-registering project URIs

Optional: one file holds the term map and registers a project-owned URI. Parser limits below apply.

Source alpha-centauri.yamlld

'@context': https://example.org/contexts/combined/person
$id: http://dbpedia.org/resource/Alpha_Centauri
name: Alpha Centauri

Source person.yamlld

'@context':
- https://example.org/contexts/combined/dollar
- name: https://schema.org/name
'@type': http://www.w3.org/ns/json-ld#Context
http://schema.org/contentUrl:
  '@id': https://example.org/contexts/combined/person

Source z-dollar.yamlld

'@context':
  $id: '@id'
'@id': https://example.org/contexts/combined/dollar
'@type':
- http://schema.org/MediaObject
- http://www.w3.org/ns/json-ld#Context
http://schema.org/contentUrl:
  '@id': https://example.org/contexts/combined/dollar

z-dollar.yamlld is only a nested-registration fixture. Ordinary sources get $id from the default context.

Source materialized-contexts.rq

PREFIX jsonld: <http://www.w3.org/ns/json-ld#>
PREFIX schema: <http://schema.org/>

SELECT ?file ?url WHERE {
  GRAPH ?file {
    [] a jsonld:Context ;
       schema:contentUrl ?url .
  }
}

Term definitions come only from the @context member (JSON-LD context processing).

Source alpha-centauri.rq

SELECT ?name WHERE { <http://dbpedia.org/resource/Alpha_Centauri> <https://schema.org/name> ?name }
name
Alpha Centauri
Alpha Centauri
Alpha Centauri
Alpha Centauri
Alpha Centauri

Bootstrap and paths

  • Write jsonld:Context and schema:contentUrl as full IRIs. sparqld retries failed sources when registrations appear. Filename order does not matter.
  • Registration dependencies must be acyclic.
  • Include registration sources in --pattern selection. Reading a body as a context does not load its registration triples.
  • The registered graph is the file that contains the node. Neither @id nor @base selects another file.
  • Relative references inside a requested context resolve from that context's requested URI, so they need their own registrations.

An @context array composes in order. @import requires an object, not an array.

Current failure limits

With sparqld 0.1.6 and oxjsonld 0.2.5, a recursive relative self-context triggers The remote context stack is invalid. The process stays up, but the HTTP endpoint never becomes ready. Keep this layout restricted until an update resolves the error. Regression tests preserve the expected failure.