Skip to content
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

Difference in behavior when using embedded vs. referenced context #379

Open
rorlic opened this issue Nov 7, 2024 · 3 comments
Open

Difference in behavior when using embedded vs. referenced context #379

rorlic opened this issue Nov 7, 2024 · 3 comments

Comments

@rorlic
Copy link

rorlic commented Nov 7, 2024

Describe the bug
The @base is handled differently when referencing a context vs. when embedding a context. When using an embedded context containing a @base, it is used - as expected - for creating a valid URI from relative properties and values. However, when referencing the same context, it seems that the @base is not used, resulting in different behavior.

To Reproduce
In order to easy showcase the issue I use the latest Jena (5.2.0) command line tools which according to the Jena developers now use titanium.

Example files:

Pre-requisites:

  • download the Jena 5.2.0 from here
  • extract the zip or tar file to a location of your choice
  • open a terminal and add this {install-location}/bin to your path, e.g. set PATH=$PATH:{install-location}/bin
  • download the example files (not the referenced context)

Steps to reproduce the behavior:

  1. run riot with the embedded context example: riot --base=http://should-not-happen.org embedded-context.jsonld
    this results in:
<https://example.com/id/1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/#something> .
<https://example.com/id/1> <http://example.com/#property> "anything" .
<https://example.com/id/1> <http://www.w3.org/2000/01/rdf-schema#label> "A simple document" .
  1. run riot with the referenced context example: riot --base=http://should-not-happen.org referenced-context.jsonld
    this results in:
<https://example.com/id/1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://should-not-happen.org#something> .
<https://example.com/id/1> <http://should-not-happen.org#property> "anything" .
<https://example.com/id/1> <http://www.w3.org/2000/01/rdf-schema#label> "A simple document" .

Expected behavior
I would expect that both would return the same result as it should not make any difference if the context is embedded or referenced. Am I correct in my assumption or am I missing something here?

@rorlic
Copy link
Author

rorlic commented Nov 7, 2024

FYI: the JSON-LD playground produces the same result for both examples:

<https://example.com/id/1> <http://example.com/#property> "anything" .
<https://example.com/id/1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/#something> .
<https://example.com/id/1> <http://www.w3.org/2000/01/rdf-schema#label> "A simple document" .

@rorlic
Copy link
Author

rorlic commented Nov 7, 2024

The referenced context is as follows:

{
  "@context": {
    "@base": "http://example.com/",
    "@vocab": "#",
    "label": "http://www.w3.org/2000/01/rdf-schema#label"
  }
}

The root cause of the problem is the relative "@vocab": "#" and can be fixed by prepending it with the @base value, i.e. "@vocab": "http://example.com/#". Unfortunately, we do not always have control over the context so a fix in Titanium would be appreciated.

@filip26
Copy link
Owner

filip26 commented Nov 8, 2024

Thank you for reporting it.

Unfortunately, we do not always have control over the context so a fix in Titanium would be appreciated.

The fastest way is to contribute and open PR.

I would appreciate many things..., starting with less greedy companies, paying back for an open-source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants