Skip to content

Remote contexts

sparqld does not download context URLs (except the embedded default). An absolute context URI fails until a local registration supplies its body.

An unregistered URL fails

Source alpha-centauri.jsonld

{
  "@context": "https://example.org/unregistered-demo-context",
  "@id": "http://dbpedia.org/resource/Alpha_Centauri",
  "name": "Alpha Centauri"
}

Source unregistered-dependencies.rq

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

SELECT ?file ?context
WHERE {
  GRAPH <sparqld:> {
    BIND(<sparqld:examples/recursive-context/unregistered/alpha-centauri.jsonld> AS ?file)
    ?file jsonld:context ?context .
  }
}
ORDER BY ?context
file context
sparqld:examples/recursive-context/unregistered/alpha-centauri.jsonld https://example.org/unregistered-demo-context

Source unregistered-failures.rq

PREFIX rlog: <http://persistence.uni-leipzig.org/nlp2rdf/ontologies/rlog#>

SELECT ?file
WHERE {
  GRAPH <sparqld:> {
    BIND(<sparqld:examples/recursive-context/unregistered/alpha-centauri.jsonld> AS ?file)
    ?error rlog:resource ?file .
  }
}
file
sparqld:examples/recursive-context/unregistered/alpha-centauri.jsonld

Source unregistered-alpha-centauri.rq

ASK {
  GRAPH <sparqld:examples/recursive-context/unregistered/alpha-centauri.jsonld> {
    <http://dbpedia.org/resource/Alpha_Centauri> <https://schema.org/name> "Alpha Centauri" .
  }
}
Expected result
False

Acquire the context with vitrify

iolanta-tech/vitrify writes the registration. Install and run vitrify context:

Command

cargo install vitrify

Command

vitrify context https://www.w3.org/ns/solid/oidc-context.jsonld --as yamlld > contexts/oidc-context.yamlld

Put that file under the served directory. The failure/success demo below uses a tiny offline stand-in URL with the same registration shape:

Source example.jsonld

{
  "@context": {
    "name": "https://schema.org/name"
  },
  "@type": "http://www.w3.org/ns/json-ld#Context",
  "http://schema.org/contentUrl": {
    "@id": "https://example.org/ctx"
  }
}

After registration

Source alpha-centauri.jsonld

{
  "@context": "https://example.org/ctx",
  "@id": "http://dbpedia.org/resource/Alpha_Centauri",
  "name": "Alpha Centauri"
}

Source registered-dependencies.rq

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

SELECT ?file ?context
WHERE {
  GRAPH <sparqld:> {
    BIND(<sparqld:examples/recursive-context/project/alpha-centauri.jsonld> AS ?file)
    ?file jsonld:context ?context .
  }
}
ORDER BY ?context
file context
sparqld:examples/recursive-context/project/alpha-centauri.jsonld https://example.org/ctx

Source registered-declaration.rq

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

ASK {
  GRAPH <sparqld:examples/recursive-context/project/example.jsonld> {
    [] a jsonld:Context ;
      schema:contentUrl <https://example.org/ctx> .
  }
}
Expected result
True

Source registered-failures.rq

PREFIX rlog: <http://persistence.uni-leipzig.org/nlp2rdf/ontologies/rlog#>

SELECT ?file
WHERE {
  GRAPH <sparqld:> {
    BIND(<sparqld:examples/recursive-context/project/alpha-centauri.jsonld> AS ?file)
    ?error rlog:resource ?file .
  }
}
file

Source registered-alpha-centauri.rq

ASK {
  GRAPH <sparqld:examples/recursive-context/project/alpha-centauri.jsonld> {
    <http://dbpedia.org/resource/Alpha_Centauri> <https://schema.org/name> "Alpha Centauri" .
  }
}
Expected result
True

Several nodes may share one body. Distinct bodies for one URI are a load error. Changing a registered body reloads sources that requested it.

Authored contexts: Project contexts.