-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamically generate JSON-LD context files based on used ontologies #1205
Comments
Finally, allowing to register ontologies dynamically will be needed because, for ActivityPods 2.0, we want containers to be automatically created with the prefix of the ontology. So instead of having hard-coded core ontologies, we will create a new
The On ActivityPods, ontologies that are registered dynamically by external appliactions will use the prefix from prefix.cc and not pass any OWL file or JSON-LD context, as we can do without that. |
I like that idea - it has the positive side effect of adding typing support which reduces bugs and improves developer experience.
I'm not sure if I understand that correctly. Json-ld would go with overriding less recent definitions, if there are multiple, unless a Maybe I don't quite understand the use case of the issue yet. So the idea is that if no And could we add a default context value for a specific resource or container which is used if no |
I've been writing tests for that today, and indeed it seems validation fails only when the
Yes exactly ! In ActivityPods, this will replace the
It could be interesting to provide such an endpoint (mostly for frontend apps). Not sure what path to use though. This makes me realize that every Pod should, in theory, have its own JSON-LD context, since it depends on the applications that were installed... But that's not how I went with the implementation so far (the ontologies are saved on the general
ActivityStreams will necessarily be in the core ontologies, so its context will always be included. We will use an array of contexts instead of putting everything together like we do now in the ActivityPods context file. Something like this: "@context": [
"https://www.w3.org/ns/activitystreams",
{
"ldp": "http://www.w3.org/ns/ldp#",
...
}
] |
Thanks for the remarks! For a moment I was thinking if we could get around creating custom contexts. |
I see several options for storing these informations:
In the last option, we should avoid persisting core ontologies, and use instead the array passed to the LdpOntologiesService. This could be a good idea for other options as well, so that we don't need to store (and maintain/migrate) triples that will be replicated in all datasets. |
From what you describe, options 2 and 3 seem to be most convincing to me, since they appear to be more "transparent" about what's happening from the outside and are a bit more generalizable / closer to the specs.. |
I think I'm mixing too many problems. Application-defined ontologies are really needed at the moment only for the LDP containers path generation, and we don't need to have something perfect because this is not standard and we don't know if we will keep this in the long run. The choice of the prefix is really an internal implementation matter that has little impact on the functionning of the Pod. Other implementations could use LOV or custom prefixes databases (the general philosophy is that the containers path is not a problem, and we don't really care about it). However what we need is consistency, so that, if two applications use the same ontology, the same prefix will be used for their containers. That's why we need persistence, but it doesn't matter if this is all persisted in the same dataset (the settings dataset). What we also want is clean contexts which explicitely include the ActivityStreams context. If we put all the properties directly on the context, it will add a big ugly header and increase the response size. So a solution could be to put all these custom context properties in an pod-provider-level context file (accessible via GET), like we do on other SemApps instances with the /context.json file, except it will be dynamically generated.
I'm also in the process of splitting the |
Current usage of default JSON-LD context
Currently the default JSON-LD context (passed to LDP and ActivityPub services) is used to format (or more precisely "frame") the rough results returned by Jena Fuseki, whenever no
JsonLdContext
header is passed.Developer convenience
Having propretly formatted JSON-LD is a convenience for developers, when they browse through a LDP container.
Instead of having full URI, they can see prefixes (this also applies to Turtle format).
Instead of having
@id
for every URI, there is something more readable.If unformatted JSON-LD was returned, browser extensions like Header Editor, combined with the new
JsonLdContext
header, could however help developers see proper formatting.Moleculer services
It is also useful to pass formatted data between other Moleculer services. Moleculer services can use the
jsonContext
parameter of theldp.resource.get
action if they want to get the results framed according to the context they want. But for Moleculer events (likeldp.resource.created
), we are dependent on what the LDP service emitted.If we used rough Fuseki results, there would be some consistency also. Or better yet: expanded results, so that we are not dependant on the formatting of a particular triple store.
More generally, in all Moleculer services, we should not treat data as JSON but as RDF, and find a library to properly process data, no matter the context used.
ActivityPub federation
That's the real problem: Most ActivityPub-compatible servers treat data as JSON and don't reformat it. They generally tolerate the addition of other contexts (this is considered as the proper way to create extensions), but if you pass rough JSON-LD data, they will most likely not reframe it.
This is a problem not only for activities sent between federated servers, but also potentially for resources ("objects" in ActivityPub vocabulary) that are retrieved from the LDP server. In the ActivityPub spec, it is indicated that "Implementers SHOULD include the ActivityPub context in their object definitions. Implementers MAY include additional context as appropriate.".
One solution could be to include the ActivityStreams context in the default JSON-LD context (especially when the ActivityPub service is activated) and to ignore other contexts. Or to provide a context which fits with core ontologies (like LDP), and ignore app-specific contexts.
Proposed solution
JsonLdContext
header to get the format they need.jsonldContext
field to the ontologies definitionThe text was updated successfully, but these errors were encountered: