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

Parser fails quietly with an @id with no scheme #145

Closed
martinPikeGB opened this issue Feb 11, 2021 · 4 comments · Fixed by #155
Closed

Parser fails quietly with an @id with no scheme #145

martinPikeGB opened this issue Feb 11, 2021 · 4 comments · Fixed by #155
Milestone

Comments

@martinPikeGB
Copy link

martinPikeGB commented Feb 11, 2021

{
  "@id" : "x.y.z",
  "x:item" : {
    "@value" : "A_Token",
    "@type" : "http://www.w3.org/2001/XMLSchema#token"
  }
}

The above json-ld has an id with a relative (not absolute) URI.
The parser processes this as input without error but emits
no Triples output.
Code:

  try {
      JsonDocument doc = JsonDocument.of(stream);
      ToRdfApi tt = JsonLd.toRdf(doc);
      RdfDataset rdf = tt.get();   
      List<RdfNQuad> list = rdf.toList();
      ....
    } catch (JsonLdError e) {
    ....
    }

The list is empty.

I believe that the parser should either:

  • process the id as-is
  • signal an error in the input format.

NOTE: Change the @id to 'urn:x.y.z' and it works fine.

@martinPikeGB
Copy link
Author

In fact, other forms of invalid URI produce the same effect.

@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

@github-actions github-actions bot added the Stale label Mar 14, 2021
@filip26 filip26 removed the Stale label Mar 17, 2021
@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

@github-actions github-actions bot added the Stale label Apr 17, 2021
@filip26 filip26 removed the Stale label Apr 19, 2021
@filip26
Copy link
Owner

filip26 commented Apr 22, 2021

Hi,
the issue is that x.y.z is relative and document Url is not set. toRdf sees x.y.z as non well-formed subject and silently skips - see the spec. step 1.3.1.

Try set document Url manually e.g. doc.setDocumentUrl(URI.create("https://apicatog.com"));

  try {
      JsonDocument doc = JsonDocument.of(stream);
      doc.setDocumentUrl(URI.create("https://apicatog.com"));

      List<RdfNQuad> list = JsonLd.toRdf(doc).get().toList();
      ....
    } catch (JsonLdError e) {
    ....
    }

result:

<https://apicatog.com/x.y.z> <x:item> "A_Token"^^<http://www.w3.org/2001/XMLSchema#token> .

Version 1.0.3 will print a warning that document Url is not set.

@filip26 filip26 added this to the 1.0.3 milestone Apr 22, 2021
filip26 added a commit that referenced this issue Apr 23, 2021
@filip26 filip26 linked a pull request Apr 23, 2021 that will close this issue
filip26 added a commit that referenced this issue Apr 23, 2021
Print a warning if a subject is not well-formed IRI (#145)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants