Code Monkey home page Code Monkey logo

Comments (9)

danbri avatar danbri commented on September 24, 2024

The main Schema.org site should have the headers discussed now, i.e.

  • access-control-allow-credentials: true
  • access-control-allow-headers: Accept
  • access-control-allow-origin: *
  • link: </docs/jsonldcontext.jsonld>; rel="alternate"; type="application/ld+json"

from rdflib-jsonld.

danbri avatar danbri commented on September 24, 2024

@hsolbrig can you suggest a workaround, at least for short term use? Can we pass in the context when invoking parser (by URL or by content?) /cc @Gnomus042

from rdflib-jsonld.

westurner avatar westurner commented on September 24, 2024

Is there no way to do this without requiring a custom HTTP header? Why is that part of the data specified out-of-band from the rest of the document?

(edit) Static files (with no HTTP server configuration dependency) are most scalable and archivable.

from rdflib-jsonld.

nicholascar avatar nicholascar commented on September 24, 2024

@rob-metalinkage, is this going to cause problems for JSON- > JSON-LD expansion due to the separate Context?

from rdflib-jsonld.

nicholascar avatar nicholascar commented on September 24, 2024

@danbri, @westurner, @hsolbrig RDFlib maintainers are assembling volunteers to complete this tools' JSON-LD 1.1 implementation and then to merge it into RDFlib core. That should make it easier for all to just "do" JSON-LD with RDFlib.

from rdflib-jsonld.

rob-metalinkage avatar rob-metalinkage commented on September 24, 2024

@nicholascar I dont think it causes any extra problems, as using just a model namespace to perform JSON->JSON-LD expansion is unsafe anyway.

The patterns appearing to be in the wild seems to be:

Data model = X
context URI = .json

i.e. there is no way to discover for a model X the relevant context file.

Or the requirement to perform content negotation is based on a model

Datamodel = X
Context = X (Accept ld+json)

this is being taken off the table as a bad idea according to this issue, but it has a deeper issue IMHO that if your data model is described in OWL , then ld+json should be the data model serialised as JSON-LD, not necessarily a JSON-LD context for the model.

The options for canonical mechanisms to discover the actual URL for a context seems to be:
a) returns Link header for alternates
b) supports a Profile "alt" which can be accessed for by either header or a URL parameter<X?_profile=jsoncontext> where the profile jsoncontext is registered and well-known. (dx-prof-conneg)

if dx-prof-conneg supports the same Link syntax and if a resource chooses to embed the Link headers for all the available profiles and serialisations from the "alt" view by default the two approaches are consistent I think.

I'd always choose the latter, as JSON context is not the only resource I'd want to be able to discover about a model. JSON-schema is also valuable, and SHACL and HTML and maybe other forms.

from rdflib-jsonld.

westurner avatar westurner commented on September 24, 2024

Maybe I'm misunderstanding? From https://www.w3.org/TR/json-ld11/#the-context ::

Contexts can either be directly embedded into the document (an embedded context) or be referenced using a URL. Assuming the context document in the previous example can be retrieved at https://json-ld.org/contexts/person.jsonld, it can be referenced by adding a single line and allows a JSON-LD document to be expressed much more concisely as shown in the example below:

{
 "@context": "https://json-ld.org/contexts/person.jsonld",

from rdflib-jsonld.

rob-metalinkage avatar rob-metalinkage commented on September 24, 2024

@westurner you are right it doesnt need necessarily need a custom header, but there are a couple of things that need care here:

  1. the agent that is "adding a single line" somehow has to know the URL "https://json-ld.org/contexts/person.jsonld"

we can say its all client code to tell RDF lib exactly what to include and maybe not think about this - but this issue is about other approaches such as trying to resolve namespaces such as schema.org and getting a context.

  1. contexts may include other contexts - so the behaviour needs to be explicit in terms of exactly how to handle potential conflicts (prefix strings bound to different URIs) and default namespaces (@value, @base) - having been exploring this I find the JSON-LD documentation extremely hard to follow and lacking basic examples, and RDFLib is silent. IMHO RDFlib should encapsulate and explain basic practices here without needing interpretation of JSON-LD specification to get started.

  2. there seem to be quite a lot of ways to bundle a set of object descriptions in JSON-LD - including arrays, @graph constructs, container objects etc. Probably the JSON-LD serialiser needs to be able to handle these if we want to deliver a a serialisation for use in a specific context - such as to meet an API payload requirement. The JSON-LD framing spec makes this clear - see #95

from rdflib-jsonld.

datamusee avatar datamusee commented on September 24, 2024

I think the following code (failing to load the schema.org context) is linked to the present problem, but doesn't understand the workaround
`from rdflib import Graph, plugin
from rdflib.serializer import Serializer

jsonldSample = """
{
"@context": "https://schema.org",
"@type": "LocalBusiness",
"name": "La Tour Eiffel",
"address": {
"@type": "PostalAddress",
"addressLocality": "Paris",
"addressRegion": "75007",
"streetAddress": "Champ de Mars, 5 Avenue Anatole France"
},
"description": "Monument emblématique de Paris, la tour Eiffel est une tour de fer puddlé de 324 mètres de hauteur construite par Gustave Eiffel à l’occasion de l’Exposition Universelle de 1889 et qui célébrait le premier centenaire de la Révolution française.",
"url": "https://www.toureiffel.paris",
"image": "https://www.toureiffel.paris/sites/default/files/2017-10/monument-landing-header-bg_0.jpg",
"pricerange": "de 2,5 à 25 euros",
"telephone": "08 92 70 12 39"
}
"""

g = Graph().parse(data=jsonldSample, format='json-ld')
print(g.serialize(format='json-ld', indent=4))
print(g.serialize(format='nt', indent=4))`

from rdflib-jsonld.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.