[GitHub] jena issue #235: jsonld: @vocab in @context for "" ns prefix

2017-04-09 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/235
  
> Does this complete JENA-1292?

yes.

In JENA-1292's discussion I had suggested a way to automatically remove 
from the @context the properties that belong to the @vocab, but it is not a 
good idea. It adds unnecessary complexity, as same result can be achieved by a 
user with a few lines of code, and existing features (possibility to replace 
the @context by a given value in the jsonld output)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request #211: writing jsonld: preserve id of blanknodes if they ar...

2017-04-09 Thread fpservant
Github user fpservant closed the pull request at:

https://github.com/apache/jena/pull/211


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #211: writing jsonld: preserve id of blanknodes if they are valid...

2017-04-09 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/211
  
closing this, as more work is still needed 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request #235: jsonld: @vocab in @context for "" ns prefix

2017-04-09 Thread fpservant
GitHub user fpservant opened a pull request:

https://github.com/apache/jena/pull/235

jsonld: @vocab in @context for "" ns prefix

"" prefix are not allowed in jsonld's @context. "" ns prefix defined in a 
model were therefore ignored. This pull request proposes to define @vocab with 
the ns corresponding to such an "" prefix. Everything else remained unchanged.

cf. JENA-1292



You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/fpservant/jena atvocabNEW2

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/jena/pull/235.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #235


commit d81a0f0e35aba7b86b979574b2e3a33c4e4a1f78
Author: François-Paul Servant <f...@semanlink.net>
Date:   2017-04-08T19:49:42Z

jsonld: @vocab in @context for "" ns prefix




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #211: writing jsonld: preserve id of blanknodes if they are valid...

2017-04-08 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/211
  
@afs sorry for the time before coming back to this. I just tried in class 
``JenaRDF2JSONLD`` to replace (first line of constructor)

```
 NodeToLabel labels = SyntaxLabels.createNodeToLabel() ;
```
by :
```
NodeToLabel labels = NodeToLabel.createBNodeByLabelAsGiven();
```

and it seems to work, but it is not really nice to have ids such as 
"_:b85f698a-0bfc-40e9-8458-4a200f6cf908" when none has been given by the user. 
It looks like mixing labels given by the user and labels such as "_:b1" 
otherwise would require to add a flag to the Node class, right?

I'm afraid I don't have time now to look into that. So maybe this PR should 
be closed for now.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #211: writing jsonld: preserve id of blanknodes if they are valid...

2017-01-31 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/211
  
@afs OK, that was a quick hack, based on the existing. I'll need more time, 
then


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #211: writing jsonld: preserve id of blanknodes if they are valid...

2017-01-31 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/211
  
@afs yes


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request #211: writing jsonld: preserve id of blanknodes if they ar...

2017-01-31 Thread fpservant
GitHub user fpservant opened a pull request:

https://github.com/apache/jena/pull/211

writing jsonld: preserve id of blanknodes if they are valid jsonld 
identifiers

current process to output jsonld computes identifiers for the blanknodes: 
_:b0, _:b1, etc.
Ids of blanknodes defined by the user (using AnonId.create()) are not used, 
even when they are valid jsonld blanknode identifiers.
Of course, this is just a cosmetic question - but if one took care to 
define valid bn identifiers, why wouldn't they be used in the output ?
This PR allows just that - with a limit: user defined identifiers beginning 
with "_:b" are not preserved (this, to avoid clash with those generated by jena)


You can merge this pull request into a Git repository by running:

$ git pull https://github.com/fpservant/jena master

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/jena/pull/211.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #211


commit 216111f1031482a68dcc1b6068c37adc84a7ee8b
Author: François-Paul Servant <f...@semanlink.net>
Date:   2017-01-31T09:06:25Z

writing jsonld: preserve id of blanknodes if they are valid jsonld
blanknode identifiers

commit 767bf5b261782b87f489a2f509fa743f7dea3541
Author: François-Paul Servant <f...@semanlink.net>
Date:   2017-01-31T09:18:19Z

cleaning

commit 849e070ad1122ad28bc080d295c8d174aa87af95
Author: François-Paul Servant <f...@semanlink.net>
Date:   2017-01-31T09:28:24Z

improved test




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request #207: JsonLDWriter.toJsonLDJavaAPI: create a JsonLD API ob...

2017-01-25 Thread fpservant
GitHub user fpservant opened a pull request:

https://github.com/apache/jena/pull/207

JsonLDWriter.toJsonLDJavaAPI: create a JsonLD API object from jena data

small refactoring of JsonLDWriter to expose a static method that allows to 
convert jena RDF data to JsonLD-java API's object.

This can be useful, because you can then modify this object (a Map 
representing the jsonld) the way you want (for instance, to reorder the items 
it contains to put more important ones at the beginning, or to make it look 
more "jsonish".)





You can merge this pull request into a Git repository by running:

$ git pull https://github.com/fpservant/jena master

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/jena/pull/207.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #207


commit 872c2897af3e99e111719bb45ddde499d04d142b
Author: François-Paul Servant <f...@semanlink.net>
Date:   2017-01-26T01:06:43Z

JsonLDWriter.jsonLDJavaAPIObject to convert a Jena dataset to a
JsonLD-java API object

commit e0c7aaa00977e1b990991276346978848530b403
Author: François-Paul Servant <f...@semanlink.net>
Date:   2017-01-26T01:16:32Z

toJsonLDJavaAPI: name and order of params changed




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #203: JsonLDReader: possibility to override the @context

2017-01-12 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/203
  
@afs jsonld-java 0.9.0 solves the issue (and I have been able to run maven 
install on jena-arq with it).

How do you want to handle jsonld-java's version change? Other PR? Shouldn't 
I wait until then before closing JENA-1276?



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #203: JsonLDReader: possibility to override the @context

2017-01-12 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/203
  
>> current jena has a problem reading JSON-LD

> jsonld-java is reporting an error, all Jena does, and can do, is pass 
that error upwards.

reformulating: I have problem with current "jena as a whole, including 
jsonld-java" to read some JSON-LD

and therefore:

> I'd be curious to know whether someone else, who is completely sure about 
its settings, also gets this problem (or not)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #203: JsonLDReader: possibility to override the @context

2017-01-11 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/203
  
Hi,

there are very different points in the discussion, all around one test that 
attempts to connect to an external resource.

1) It must first be noted that the test in question actually doesn't have 
anything to do with the functionality that the PR proposes. It can as well be 
removed, and that wouldn't change anything about the object of the PR (the 
functionality that it proposes to add), nor about the completeness of the 
testing of that functionality.

If you want, I can remove it.

2) this test attempts to parse some JSON-LD whose @context contains the URI 
of schema.org - probably the most obvious use-case for reading JSON-LD

- BTW, I didn't see any test about reading JSON-LD. Are there any?

 - If this test cannot connect to schema.org because there are no 
external connection, (or for whatever reason) the test won't fail, because the 
RiotException is catched. Just one line is written to the console (and it is 
not by the test itself, but by the code that it calls). So this test with this 
external connection doesn't really cause trouble to the integration process 
(maybe a few seconds delay - the time for the HTTP client to stop trying to 
connect)

 - it shows me that I'm not able to read such JSON-LD on my machine (I 
get on the console: ```org.apache.jena.riot.RiotException: loading remote 
context failed: http://schema.org/```) - this, in a setting where it should 
work (standard jena 3.1.1, run from eclipse where I can connect to external 
resources from java, for instance using jersey client)

So: as far as I can tell (thanks to this test), current jena has a problem 
reading JSON-LD with @context set to a URI (at least, I have such a problem 
using current jena)

- it is probably possible to write a test that simulates connecting to an 
external resource without connecting to it (cf. "cache" mechanism in JSON-LD 
java), but
- such a test would probably not detect a problem such as the one we 
seem to have here
- it's out of the scope of current PR 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #203: JsonLDReader: possibility to override the @context

2017-01-10 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/203
  
@ajs6f are you speaking of the "org.apache.jena.riot.RiotException: loading 
remote context failed" thing? 

1) note that in the context of a test, jena doesn't want to depend on a 
connexion to the network (so told me @afs when I was working on JSON-LD writing 
- and getting, BTW, same kind of problem, for reasons which are supposed to 
have been solved since). So the catch Exception must probably stay in the code 
of the test.

2) I'd be curious to know whether someone else, who is completely sure 
about its settings, also gets this problem (problems with http connexions may 
be many different things!) (Other people experiment it, cf. question on 
jena-users that initiated this PR, but are they up-to-date?). So I would be 
happy to get confirmation of the problem from others.

I tried to track it down. It occurs to me at 
```com.github.jsonldjava.core.DocumentLoader.loadDocument(String)``` line 29

where I get:
```org.apache.http.ConnectionClosedException: Premature end of 
Content-Length delimited message body (expected: 124346; received: 0```




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request #203: JsonLDReader: possibility to override the @context

2017-01-09 Thread fpservant
Github user fpservant commented on a diff in the pull request:

https://github.com/apache/jena/pull/203#discussion_r95216878
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/riot/out/JenaRDF2JSONLD.java ---
@@ -0,0 +1,100 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.riot.out;
+
+import java.util.Iterator ;
+
+import org.apache.jena.atlas.logging.Log ;
+import org.apache.jena.datatypes.xsd.XSDDatatype ;
+import org.apache.jena.graph.Node ;
+import org.apache.jena.riot.RiotException ;
+import org.apache.jena.riot.system.SyntaxLabels ;
+import org.apache.jena.sparql.core.DatasetGraph ;
+import org.apache.jena.sparql.core.Quad ;
+
+import com.github.jsonldjava.core.JsonLdError ;
+import com.github.jsonldjava.core.RDFDataset ;
+
+/** Convert from JSON-LD syntax to JSON-LD internal representation of a 
dataset, using Jena Quads/Nodes etc */
+class JenaRDF2JSONLD implements com.github.jsonldjava.core.RDFParser {
+NodeToLabel labels = SyntaxLabels.createNodeToLabel() ;
+
+@Override
+public RDFDataset parse(Object object) throws JsonLdError {
+RDFDataset result = new RDFDataset() ;
+if ( object instanceof DatasetGraph )
+{
+DatasetGraph dsg = (DatasetGraph)object ;
+
+Iterator iter = dsg.find() ;
+for ( ; iter.hasNext() ; )
--- End diff --

Hmm, that's not code that I wrote, so I don't feel like taking the risk of 
adding a bug to something that works, just for aesthetic reasons...


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request #203: JsonLDReader: possibility to override the @context

2017-01-09 Thread fpservant
Github user fpservant commented on a diff in the pull request:

https://github.com/apache/jena/pull/203#discussion_r95170644
  
--- Diff: 
jena-arq/src/main/java/org/apache/jena/riot/lang/JsonLDReader.java ---
@@ -45,9 +45,20 @@
 import org.apache.jena.riot.system.* ;
 import org.apache.jena.sparql.core.Quad ;
 import org.apache.jena.sparql.util.Context ;
+import org.apache.jena.sparql.util.Symbol;
 
 public class JsonLDReader implements ReaderRIOT
 {
+private static final String SYMBOLS_NS = 
"http://jena.apache.org/riot/jsonld#; ;
+/**
+ * Symbol to use to pass the "@context" to be used when reading the 
jsonld
+ * (overriding the actual @context in the jsonld)
+ * Expected value: the value of the "@context", 
+ * as expected by the JSONLD-java API (a Map) */
+public static final Symbol JSONLD_CONTEXT = Symbol.create(SYMBOLS_NS + 
"JSONLD_CONTEXT");
--- End diff --

done


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #203: JsonLDReader: possibility to override the @context

2017-01-09 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/203
  
@afs I think that @ajs6f refers to code:
```
InputStream in = new 
ByteArrayInputStream(jsonld.getBytes(StandardCharsets.UTF_8));
+Dataset ds = DatasetFactory.create();
+ReaderRIOT reader = RDFDataMgr.createReader(Lang.JSONLD);
(etc)
```
he commented:

> This whole section seems complex. How about 
org.apache.jena.riot.RDFDataMgr.read(Model, StringReader, String, Lang)?

and I replied:

> Hmm, maybe I'm missing something obvious, but I need to pass the Context. 
I didn't find an easier way (all read methods in RDFDataMgr that take the 
Context as arg use the uri param to define what we read).

and:
> I'd be happy to learn about a better way to read data from an 
InputStream, that supports the passing of a Context


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #203: JsonLDReader: possibility to override the @context

2017-01-08 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/203
  
@ajs6f thanks for the review. I made most (all ?) of the changes that you 
suggested. Remains the problem "loading remote context failed: 
http://schema.org/; - unrelated to this PR per se.

Regarding the section that you find too complex: I'd be happy to learn 
about a better way to read data from an InputStream, that supports the passing 
of a Context


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request #203: JsonLDReader: possibility to override the @context

2017-01-08 Thread fpservant
Github user fpservant commented on a diff in the pull request:

https://github.com/apache/jena/pull/203#discussion_r95095721
  
--- Diff: jena-arq/src/test/java/org/apache/jena/riot/TestJsonLDReader.java 
---
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.riot;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.nio.charset.StandardCharsets;
+
+import org.apache.jena.query.Dataset;
+import org.apache.jena.query.DatasetFactory;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.ModelFactory;
+import org.apache.jena.riot.lang.JsonLDReader;
+import org.apache.jena.riot.system.StreamRDFLib;
+import org.apache.jena.sparql.util.Context;
+import org.apache.jena.vocabulary.RDF;
+import org.junit.Test;
+
+import com.fasterxml.jackson.core.JsonGenerationException;
+import com.github.jsonldjava.utils.JsonUtils;
+
+public class TestJsonLDReader {
+
+@Test public final void test() {
+try {
+String jsonld = 
"{\"@id\":\"_:b0\",\"@type\":\"http://schema.org/Person\",\"name\":\"John 
Doe\",\"@context\":\"http://schema.org/\"};;
+StringReader reader = new StringReader(jsonld);
+Model m = ModelFactory.createDefaultModel();
+m.read(reader, null, "JSON-LD");
+m.write(System.out, "TURTLE");
+} catch (Throwable e) {
+e.printStackTrace();
--- End diff --

I changed that, but I get the ```org.apache.jena.riot.RiotException: 
loading remote context failed: http://schema.org/```here - that's bad, but not 
related to this PR (which, in fact, gives a way to get rid of the problem)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request #203: JsonLDReader: possibility to override the @context

2017-01-08 Thread fpservant
Github user fpservant commented on a diff in the pull request:

https://github.com/apache/jena/pull/203#discussion_r95095597
  
--- Diff: jena-arq/src/test/java/org/apache/jena/riot/TestJsonLDReader.java 
---
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.riot;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.nio.charset.StandardCharsets;
+
+import org.apache.jena.query.Dataset;
+import org.apache.jena.query.DatasetFactory;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.ModelFactory;
+import org.apache.jena.riot.lang.JsonLDReader;
+import org.apache.jena.riot.system.StreamRDFLib;
+import org.apache.jena.sparql.util.Context;
+import org.apache.jena.vocabulary.RDF;
+import org.junit.Test;
+
+import com.fasterxml.jackson.core.JsonGenerationException;
+import com.github.jsonldjava.utils.JsonUtils;
+
+public class TestJsonLDReader {
+
+@Test public final void test() {
+try {
+String jsonld = 
"{\"@id\":\"_:b0\",\"@type\":\"http://schema.org/Person\",\"name\":\"John 
Doe\",\"@context\":\"http://schema.org/\"};;
+StringReader reader = new StringReader(jsonld);
+Model m = ModelFactory.createDefaultModel();
+m.read(reader, null, "JSON-LD");
+m.write(System.out, "TURTLE");
+} catch (Throwable e) {
+e.printStackTrace();
+}
+}
+   
+/** test using the jena Context mechanism to pass the jsonld 
"@context" */
+@Test public final void replaceAtContextTest() throws 
JsonGenerationException, IOException {
+ // some jsonld using schema.org's URI as "@context"
+String jsonld = 
"{\"@id\":\"_:b0\",\"@type\":\"Person\",\"name\":\"John 
Doe\",\"@context\":\"http://schema.org/\"};;
+
+// a subset of schema.org that can be used as @context for jsonld
+String jsonldContext = 
"{\"name\":{\"@id\":\"http://schema.org/name\"},\"Person\": {\"@id\": 
\"http://schema.org/Person\"}};;
+
+// pass the jsonldContext to the read using a jena Context
+Context jenaCtx = new Context();
+Object jsonldContextAsMap = JsonUtils.fromInputStream(new 
ByteArrayInputStream(jsonldContext.getBytes(StandardCharsets.UTF_8)));
+jenaCtx.set(JsonLDReader.JSONLD_CONTEXT, jsonldContextAsMap);
+
+// read the jsonld, replacing its "@context"
+InputStream in = new 
ByteArrayInputStream(jsonld.getBytes(StandardCharsets.UTF_8));
+Dataset ds = DatasetFactory.create();
+ReaderRIOT reader = RDFDataMgr.createReader(Lang.JSONLD);
--- End diff --

Hmm, maybe I'm missing something obvious, but I need to pass the Context. I 
didn't find an easier way (all read methods in RDFDataMgr that take the Context 
as arg use the uri param to define what we read).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request #203: JsonLDReader: possibility to override the @context

2017-01-08 Thread fpservant
GitHub user fpservant opened a pull request:

https://github.com/apache/jena/pull/203

JsonLDReader: possibility to override the @context

following a question on the user list: "[Overriding @context when loading 
JSON-LD](http://jena.markmail.org/message/uf3zkzybv7gb4crt)",
a way using the jena Context mechanism to do just that.
This also allows to not depend on jsonld-java to download a context defined 
by a URI.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/fpservant/jena master

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/jena/pull/203.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #203


commit 6696ff614605070abc6fea6db5c29e8d96145054
Author: François-Paul Servant <f...@semanlink.net>
Date:   2017-01-09T00:32:44Z

Reading JSON-LD: possibility to pass the "@context" using the jena
Context

commit 990b7f980d99825687a7e4b6bf957a4c83608ba7
Author: François-Paul Servant <f...@semanlink.net>
Date:   2017-01-09T00:44:09Z

Moved TestJsonLDReader out of the writer package

commit dfa49580943a2a6a49adaf4b29cf94ea81441dd4
Author: François-Paul Servant <f...@semanlink.net>
Date:   2017-01-09T01:04:56Z

JsonLDReader: improve comment about JSONLD_CONTEXT Symbol




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


CMS diff: Writing RDF in Apache Jena

2016-10-15 Thread fpservant
Clone URL (Committers only):
https://cms.apache.org/redirect?new=anonymous;action=diff;uri=http://jena.apache.org/documentation%2Fio%2Frdf-output.mdtext

fpservant

Index: trunk/content/documentation/io/rdf-output.mdtext
===
--- trunk/content/documentation/io/rdf-output.mdtext(revision 1655891)
+++ trunk/content/documentation/io/rdf-output.mdtext(working copy)
@@ -16,6 +16,7 @@
   - [N-Triples and N-Quads](#n-triples-and-n-quads)
   - [RDF Thrift](#rdf-thrift)
   - [RDF/XML](#rdfxml)
+  - [JSON-LD](#json-ld)
 - [Examples](#examples)
 - [Notes](#Notes)
 
@@ -316,6 +317,20 @@
 | RDFXML| RDFXML_PRETTY, RDF_XML_ABBREV | "RDF/XML-ABBREV" |
 | RDFXML_PLAIN || "RDF/XML"|
 
+### JSON-LD
+
+JSON-LD output is supported, in its various flavors ("compacted", "expanded", 
"flattened", "framed"), 
+by using one of the following RDFFormats:
+
+JSONLD_EXPAND_PRETTY, JSONLD_EXPAND_FLAT, JSONLD_COMPACT_PRETTY, 
JSONLD_COMPACT_FLAT, JSONLD_FLATTEN_PRETTY, JSONLD_FLATTEN_FLAT, 
JSONLD_FRAME_PRETTY, JSONLD_FRAME_FLAT
+
+The JSONLD and JSONLD_PRETTY are identical to JSONLD_COMPACT_PRETTY.
+
+Output can be customized, passing more info to the writer by using the 
"Context" mechanism provided by Jena.
+Same mechanism must be used to pass the "frame" in the JSONLD_FRAME_PRETTY and 
JSONLD_FRAME_FLAT cases.
+
+What can be done, and how it can be, is explained in the [sample 
code](https://github.com/apache/jena/tree/master/jena-arq/src-examples/arq/examples/riot/ExJsonLD.java)
+
 ## Examples
 
 Example code may be found in 
[jena-arq/src-examples](https://github.com/apache/jena/tree/master/jena-arq/src-examples/arq/examples/riot/).



[GitHub] jena issue #139: JSON-LD output

2016-10-03 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/139
  
@ajs6f ah, OK, thank you. So I'll do it shortly


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #139: JSON-LD output

2016-10-03 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/139
  
@afs thanks to you.

> What should I link to to say "it's new - read this"?

good question. I think that the best is to link to the sample code, where 
I've tried to explain what can be done, and how: 
``jena-arq/src-examples/arq/examples/riot/ExJsonLD.java``

I already had mentioned it, but note that I haven't done anything regarding 
the ["Writing RDF in Apache Jena" page]( 
https://jena.apache.org/documentation/io/rdf-output.html). The only way I saw 
is the " Improve this Page" link on the page, so this would mean that this can 
only be done after the release. Am I correct?



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #139: JSON-LD output

2016-10-02 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/139
  
@afs as I said in y previous mess, I don't seem to be able to get rid of 
the conflict (but I am not an expert with git and github) The only solution I 
see that would probably work would mean to move back ``JsonLDWriter`` from 
``org.apache.jena.riot.writer`` to ``org.apache.jena.riot``.

The merge should be simple enough: the conflicting file is to be removed 
(there is a new version of it in 
``jena-arq/src/main/java/org/apache/jena/riot/out/writer/JsonLDWriter.java``)





---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request #139: JSON-LD output

2016-10-02 Thread fpservant
Github user fpservant commented on a diff in the pull request:

https://github.com/apache/jena/pull/139#discussion_r81478977
  
--- Diff: jena-arq/pom.xml ---
@@ -85,8 +84,9 @@
 
 
 
-  com.github.jsonld-java
-  jsonld-java
+   com.github.jsonld-java
+jsonld-java
+0.8.3
 
--- End diff --

sorry. jena-arq/pom.xml now reverted to upstream/master


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #139: JSON-LD output

2016-10-02 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/139
  
@afs, 

> If possible, please see if the PR can be alighed to the current Jena 
master branch for a clean merge 

do you mean: "see if I can do something to get rid of the conflict" ?

Regarding the conflict, I tried the following: I replaced my local rio/out 
with the one from upstream/master (-> the old JsonLDWriter is back in my 
riot/out), and I committed/pushed it. (that was my "trying to solve conflict 
with master regarding JsonLDWriter" commit)
-> no more conflict.
Then I tried to delete the JsonLDWriter ("trying to solve conflict with 
master regarding JsonLDWriter, step2" commit)
-> conflict again
-> I don't know what I can do


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #139: JSON-LD output

2016-09-26 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/139
  
@stain yes, JSONLD-java can download a context from a URL, and cache it. 
The problem is, there is no way that I know of that would allow me to use that 
context in a write operation initiated from jena. I opened a JSONLD-java 
[issue](https://github.com/jsonld-java/jsonld-java/issues/184) about this.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #139: JSON-LD output

2016-09-24 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/139
  
I updated this with some sample code, and it seems to me that this is as 
good as *I* can. The sample code is the best place to learn how it works and 
what it does. 

Andy, answering your remarks (Jul 10):

> Examples can go in jena-arq/src-examples/arq/examples/riot/.

done

> A new section about JSON-LD output for 
https://jena.apache.org/documentation/io/rdf-output.html

this still has to be done, but if I understand correctly, this is the 
documentation about the release, isn't it? (so should be updated later)

> Symbols are fine but URI's please!

done

> RDFDataMgr The way to set things specially for a writing is to do:...

ok. No new "write" methods with a Context argument (as there were in my 
frist attempt)

> If you want, add a new API class specific to JSON output ``JsonLdMgr ``

I created only a JSONLDWriteContext class (extending Context), with setters 
for the relevant Symbols

> Constants This could be tidied out with a subclass of ``RDFFormatVariant``

see ``public static class JSONLDVariant extends RDFFormatVariant`` inside 
RDFFormat.java, with methods such as ``isCompact()``, `isFratten()``etc.

> We need to be able to run the tests without assuing that external network 
resources

done

> Code organisation. If you feel there classes, fell free to create a 
package org.apache.jena.riot.out.jsonld 

very few classes, actually.

I moved ``jena/riot/out/JsonLDWriter.java`` (and ``JenaRDF2JSONLD``) to 
``jena/riot/writer`` to have it with other writers. Only one new 
file``jena/riot/JsonLDWriteContext``


> Indentation: spaces, not tabs please.

done

Tell me if you want me to change things

Best





---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #139: JSON-LD output

2016-09-20 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/139
  
Andy,
I have reverted to an unmodified version of RDFDataMgr (without write 
methods with a context param). 

I am sorry that I take so long to finalize this stuff. Remember that one 
thing that we want to be able to do is to pass a (JSONLD) context (as a jena 
context) to the Writer, in order to have it used when computing the output. But 
there is a problem with JSONLD java (see [issue 
184](https://github.com/jsonld-java/jsonld-java/issues/184)): it doesn't seem 
possible (or at least, easy) to let the user set the (JSONLD) context to 
something like ``"@context": "http://schema.org/"``. The best that I can do is 
to pass the content corresponding to the URL (downloaded and converted to a 
map) to the JSONLD API, and then to substitute the @context value with 
"http://schema.org/; at the end of the process (just before writing the output).

(I hadn't seen this problem when I created the pull request, because at 
this time, there was no way to have JSON-LD java download externally defined 
contexts, because of incompatible versions of HttpClient used by jena and 
json-ld java).

Regarding the way to expose the Symbols that can be set it the (jena) 
context, and the classes expected for the corresponding values, are you OK with 
a JSONLDWriteContext class (extending Context), with methods such as:
```
public void setOptions(JsonLdOptions opts) { 
set(JSONLD_OPTIONS_SYMBOL, opts);
}
```

I try to finalize something quickly and I update this.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #139: JSON-LD output

2016-08-25 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/139
  
Hi Andy,
getting back to this after, well, a long summer.
I have a remark regarding your following comment:
> RDFDataMgr
>
> The way to set things specially for a writing is to do:
>
>WriterDatasetRIOT w = 
RDFDataMgr.createDatasetWriter(RDFFormat.JSONLD_COMPACT_FLAT) ;
>w.write(System.out,  dataset.asDatasetGraph(), null, "http://base;, 
RIOT.getContext()) ;
> 
> rather than add RDFDataMgr.write(..., Context cxt)

I understand the point of not adding new methods to RDFDataMgr.
However:
- there are read methods with a Context param (so, we would get some 
symetry between read and write methods)
- and I have the feeling that writing down a Model gets more convoluted for 
the user without the write methods with the Context param.

If we have a write with the Context param, one just has to:
```
private void writeExample(OutputStream out, Model m, RDFFormat f, Context 
jenaContext) {
  try {
RDFDataMgr.write(out, m, f, jenaContext) ;
...
 ```

Without it:
```
private void writeExample(OutputStream out, Model m, RDFFormat f, Context 
jenaContext) {
  try {
WriterDatasetRIOT w = RDFDataMgr.createDatasetWriter(f) ;
DatasetGraph g = DatasetFactory.create(m).asDatasetGraph();
PrefixMap pm = RiotLib.prefixMap(g);
String base = null;
w.write(out,  g, pm, base, jenaContext) ;
...
 ```

I've had to search a little bit to write it. I guess that other users also 
would. Would it justify the extra RDFDataMgr.write(..., Context cxt)? That's 
the question I am asking.

Best,

fps


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #139: JSON-LD output

2016-07-10 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/139
  
Andy
> Apologies that this has taken so long.
no problem, really. Thanks for this answer. Give me some time to take all 
your valuable comments into account.

just one remark:
> I ran the tests for JSONLD but got:
>> 10:13:04 INFO  TestJsonLDWriter  :: Sorry to get this exception
>>org.apache.jena.riot.RiotException: 
com.github.jsonldjava.core.JsonLdError: loading remote context failed: 
http://schema.org/
...
> The tests and build should work if there is no extenral connectivity.

I understand the point, and I'll take it into account. But actually, I'm 
happy to see this, because it shows that one problem that I had at the time has 
been solved. As was noted in a comment in the code:
```
} catch (Throwable e) {
Logger.getLogger(getClass()).info("Sorry to get this 
exception",e);
}

// It seems to work, but there's a problem with httpclient version: the 
one used by jena
// is not compatible with the one expected by JSONLD-java API. We get
/*
java.lang.NoSuchMethodError: 
org.apache.http.impl.client.cache.CacheConfig.custom()Lorg/apache/http/impl/client/cache/CacheConfig$Builder;
```
Looks like the work on " (JENA-576) Upgrade Apache HTTP Client to 4.3" has 
solved the issue



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JSON-LD output

2016-05-10 Thread fpservant
Github user fpservant commented on a diff in the pull request:

https://github.com/apache/jena/pull/139#discussion_r62686179
  
--- Diff: 
jena-arq/src/test/java/org/apache/jena/riot/writer/TestJsonLDWriter.java ---
@@ -0,0 +1,457 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.riot.writer;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.StringReader;
+
+import org.apache.jena.atlas.json.JsonObject;
+import org.apache.jena.atlas.junit.BaseTest;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.ModelFactory;
+import org.apache.jena.rdf.model.Property;
+import org.apache.jena.rdf.model.RDFNode;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.riot.RDFDataMgr;
+import org.apache.jena.riot.RDFFormat;
+import org.apache.jena.riot.out.JsonLDWriter;
+import org.apache.jena.sparql.util.Context;
+import org.apache.jena.vocabulary.RDF;
+import org.apache.log4j.Logger;
+import org.junit.Test;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.github.jsonldjava.utils.JsonUtils;
+
+public class TestJsonLDWriter extends BaseTest {
--- End diff --

Hi again. Well you know, old user of the Model API... 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JSON-LD output

2016-05-10 Thread fpservant
Github user fpservant commented on a diff in the pull request:

https://github.com/apache/jena/pull/139#discussion_r62686055
  
--- Diff: jena-arq/src/main/java/org/apache/jena/riot/out/JsonLDWriter.java 
---
@@ -79,26 +130,85 @@ public void write(OutputStream out, DatasetGraph 
dataset, PrefixMap prefixMap, S
 IO.flush(w) ;
 }
 
-private void serialize(Writer writer, DatasetGraph dataset, PrefixMap 
prefixMap, String baseURI) {
-final Map<String, Object> ctx = new LinkedHashMap<>() ;
-addProperties(ctx, dataset.getDefaultGraph()) ;
-addPrefixes(ctx, prefixMap) ;
+private JSONLD_FORMAT getOutputFormat() {
+   if ((RDFFormat.JSONLD_COMPACT_PRETTY.equals(format)) || 
(RDFFormat.JSONLD_COMPACT_FLAT.equals(format))) return JSONLD_FORMAT.COMPACT;
+   if ((RDFFormat.JSONLD_EXPAND_PRETTY.equals(format)) || 
(RDFFormat.JSONLD_EXPAND_FLAT.equals(format))) return JSONLD_FORMAT.EXPAND;
+   if ((RDFFormat.JSONLD_FLATTEN_PRETTY.equals(format)) || 
(RDFFormat.JSONLD_FLATTEN_FLAT.equals(format))) return JSONLD_FORMAT.FLATTEN;
+   if ((RDFFormat.JSONLD_FRAME_PRETTY.equals(format)) || 
(RDFFormat.JSONLD_FRAME_FLAT.equals(format))) return JSONLD_FORMAT.FRAME;
+   throw new RuntimeException("Unexpected output format");
+}
+
+private boolean isPretty() {
--- End diff --

Hi ajs6f, thanks for the comments. Yes, it is probably clearer.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena pull request: JSON-LD output

2016-05-06 Thread fpservant
GitHub user fpservant opened a pull request:

https://github.com/apache/jena/pull/139

JSON-LD output

Hi,

here's my attempt at improving user's control over JSON-LD output and 
therefore, my request for comments.

Following discussions on jena-users list : 
[[1]](http://users.jena.apache.narkive.com/NF0pn3kq/controlling-json-ld-output) 
and 
[[2]](https://mail-archives.apache.org/mod_mbox/jena-users/201604.mbox/%3c6f2caa77-7586-4330-8903-16a81c5ab...@gmail.com%3e)

Mains functionalities:
- possibility to choose between expanded, compacted, flattened and framed 
output using different RDFFormat variants
- possibility to set the "@context" used to compute the output 
- possibility to substitute the "@context" used to compute the output by 
another one

Building on existing jena features, simple functionalities are easy to use, 
or so I hope: you just choose the RDFFormat to choose between expanded, 
compacted..: as in current jena master, a default context is computed for 
formats that need one.

Features that require passing an object to the JSON-LD API (a jsonld 
context or a frame) are built using the jena "Context" mechanism 
(``org.apache.jena.sparql.util.Context``).

The (jsonld) context and frame objects are passed as JSON strings (the user 
doesn't have to build JsonLD API objects).

The (jena) context parameter wasn't available in the write methods of 
``org.apache.jena.riot.RDFDataMgr``however. I just added ``public static void 
write(OutputStream out, Model model, RDFFormat serialization, Context ctx)``to 
it. Should we also do it for the other write methods (write(StringWriter...))? 
Yes, probably.

TODO some documentation. Where should it be added? The best form would be 
small sample code. Easy to create from the existing tests.

QUESTIONS
- it is OK to have the Symbols used by the Context in JsonLDWriter? Should 
I define one subclass of Context instead?
- As there already were a JSONLD_PRETTY and a JSONLD_FLAT RDFFormat, I felt 
obliged to create 8 different RDFFormats for JSONLD (expanded, compact, etc. * 
2 - on pretty and one flat for each, eg. JSONLD_EXPAND_FLAT). Without the 2 
pre-existing ones, I would have created only 4, and use the context to pass a 
flag pretty/flat. But now, passing this flag would add complexity without 
decreasing much the number of different RDFformats. BTW: should I create 
"aliases" such as JSONLD_COMPACT, etc.?
- There is one more functionality that I developed, but I didn't include it 
in here: the possibility to choose to prefer prefixed forms for properties over 
localname based ones in the output. Not clear? Here is an example of what we 
get, giving the way the context is computed (when there is none): 

```
{
  "@id" : "_:b0",
  "@type" : "sh:Person",
  "name" : "Jane Doe",
  "url" : "http://www.janedoe.com;,
  "@context" : {
"url" : {
  "@id" : "http://schema.org/url;
},
"name" : {
  "@id" : "http://schema.org/name;
},
"sh" : "http://schema.org/;
  }
}
```

Note the "@type" : "sh:Person", while we have "name", etc. for props. 
Person and name are however in the same vocab.

We could choose to prefer to get:

```
{
  "@id" : "_:b0",
  "@type" : "sh:Person",
  "sh:name" : "Jane Doe",
  "sh:url" : "http://www.janedoe.com;,
  "@context" : {
"sh:url" : {
  "@id" : "http://schema.org/url;
},
"sh:name" : {
  "@id" : "http://schema.org/name;
},
"sh" : "http://schema.org/;
  }
}
```
Now we have "sh:name", etc, in line with the "sh:Person"
What do you think? 

Best Regards,

fps



You can merge this pull request into a Git repository by running:

$ git pull https://github.com/fpservant/jena master

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/jena/pull/139.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #139


commit 6a0e1b5ceb111277989b891fe1fee50ab25fcf9c
Author: François-Paul Servant <f...@semanlink.net>
Date:   2016-05-05T01:11:49Z

Initial commit: RDFFormat variants for the different JSON-LD outputs.
Jena Context mechanism to allow to pass the jsonld "@context"

commit 99db17246f26b44a5b93cf22169dcddf99722ec8
Author: François-Paul Se