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

Support JSON array in @context with toRDF #104

Merged
merged 8 commits into from Mar 24, 2014

Conversation

stain
Copy link
Contributor

@stain stain commented Mar 19, 2014

JsonLdProcessor.toRDF failed if options.useNamespaces = true
and the input has an @context which is an array rather than an object - the code tried to cast to Map.

Failing JSON-LD (as verified by included test ArrayContextToRDFTest and src/test/resources/custom/array-context.jsonld):

{
  "@context": [
    "http://nonexisting.example.com/context",
    { "ex2": "http://example.com/2/" }
  ],
  "@id": "ex2:a",
  "term2": "ex2:b"
}

This suggested fix is to reuse Context to recursively parse the contexts (including doing any imports) and remove the casting.

Additionally this fix ensures that only 'common' prefixes (e.g. where the URI end with / or #) are returned - thus not poluting the RDF namespaces with "term1", "term2" etc. -- if controversial this can be reversed in the call to context.getPrefixes(true) by changing to false.

stain added a commit to wf4ever/robundle that referenced this pull request Mar 19, 2014
@ansell
Copy link
Member

ansell commented Mar 24, 2014

I will look into testing and merging this. Are you using Eclipse by the way? If so, you can install the code formatting and code cleanup configurations from the /conf/ directory to ensure that the code in pull requests is cleanly formatted and only shows the relevant changes. I am not too worried about tabs versus spaces, but we chose 4 spaces, so the current files in Git are formatted that way.

I will pull into a local branch and reformat the files for this pull request to match our styles.

@ansell ansell self-assigned this Mar 24, 2014
@ansell ansell merged commit 09095fb into jsonld-java:master Mar 24, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants