Return-Path: X-Original-To: apmail-jena-commits-archive@www.apache.org Delivered-To: apmail-jena-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7566217CD6 for ; Sat, 16 May 2015 08:58:44 +0000 (UTC) Received: (qmail 35085 invoked by uid 500); 16 May 2015 08:58:44 -0000 Delivered-To: apmail-jena-commits-archive@jena.apache.org Received: (qmail 35007 invoked by uid 500); 16 May 2015 08:58:44 -0000 Mailing-List: contact commits-help@jena.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jena.apache.org Delivered-To: mailing list commits@jena.apache.org Received: (qmail 34712 invoked by uid 99); 16 May 2015 08:58:44 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 16 May 2015 08:58:44 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 19AB4E0385; Sat, 16 May 2015 08:58:44 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: claude@apache.org To: commits@jena.apache.org Date: Sat, 16 May 2015 08:58:54 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [12/50] [abbrv] jena git commit: JENA-934: Skip a prefix of the empty string - not allowed in JSON-LD JENA-934: Skip a prefix of the empty string - not allowed in JSON-LD Project: http://git-wip-us.apache.org/repos/asf/jena/repo Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/8eeb060c Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/8eeb060c Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/8eeb060c Branch: refs/heads/add-contract-tests Commit: 8eeb060c3df48881ac98747d8e024ff89047ede3 Parents: ff8439e Author: Andy Seaborne Authored: Tue May 5 18:39:57 2015 +0100 Committer: Andy Seaborne Committed: Tue May 5 18:39:57 2015 +0100 ---------------------------------------------------------------------- .../org/apache/jena/riot/out/JsonLDWriter.java | 3 + .../jena/riot/system/TestJsonLDReadWrite.java | 7 +- jena-arq/testing/RIOT/jsonld/graph1.jsonld | 108 ++++++++++--------- jena-arq/testing/RIOT/jsonld/graph2.jsonld | 63 +++++++++++ jena-arq/testing/RIOT/jsonld/graph2.ttl | 15 +++ 5 files changed, 147 insertions(+), 49 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jena/blob/8eeb060c/jena-arq/src/main/java/org/apache/jena/riot/out/JsonLDWriter.java ---------------------------------------------------------------------- diff --git a/jena-arq/src/main/java/org/apache/jena/riot/out/JsonLDWriter.java b/jena-arq/src/main/java/org/apache/jena/riot/out/JsonLDWriter.java index dbd8fff..c7ed85a 100644 --- a/jena-arq/src/main/java/org/apache/jena/riot/out/JsonLDWriter.java +++ b/jena-arq/src/main/java/org/apache/jena/riot/out/JsonLDWriter.java @@ -115,6 +115,9 @@ public class JsonLDWriter extends WriterDatasetRIOTBase Map pmap = prefixMap.getMapping() ; for ( Entry e : pmap.entrySet() ) { String key = e.getKey() ; + if ( key.isEmpty() ) + // Prefix "" is not allowed in JSON-LD + continue ; IRI iri = e.getValue() ; ctx.put(e.getKey(), e.getValue().toString()) ; } http://git-wip-us.apache.org/repos/asf/jena/blob/8eeb060c/jena-arq/src/test/java/org/apache/jena/riot/system/TestJsonLDReadWrite.java ---------------------------------------------------------------------- diff --git a/jena-arq/src/test/java/org/apache/jena/riot/system/TestJsonLDReadWrite.java b/jena-arq/src/test/java/org/apache/jena/riot/system/TestJsonLDReadWrite.java index 3f3e949..b83e666 100644 --- a/jena-arq/src/test/java/org/apache/jena/riot/system/TestJsonLDReadWrite.java +++ b/jena-arq/src/test/java/org/apache/jena/riot/system/TestJsonLDReadWrite.java @@ -43,9 +43,13 @@ public class TestJsonLDReadWrite extends BaseTest @Test public void read_g01() { graphJ2R("graph1.jsonld", "graph1.ttl") ; } + @Test public void read_g02() { graphJ2R("graph2.jsonld", "graph2.ttl") ; } + @Test public void read_ds01() { datasetJ2R("graph1.jsonld", "graph1.ttl") ; } - @Test public void read_ds02() { datasetJ2R("dataset1.jsonld", "dataset1.trig") ; } + @Test public void read_ds02() { datasetJ2R("graph2.jsonld", "graph2.ttl") ; } + + @Test public void read_ds03() { datasetJ2R("dataset1.jsonld", "dataset1.trig") ; } private void graphJ2R(String inFile, String outFile) { @@ -144,6 +148,7 @@ public class TestJsonLDReadWrite extends BaseTest if (namespaces == null) return; for (String prefix : namespaces.keySet()) { + if ( ! prefix.isEmpty() ) Assert.assertEquals("Model does contain expected namespace " + prefix + ": <" + namespaces.get(prefix) + ">", namespaces.get(prefix), m.getNsPrefixURI(prefix)); } } http://git-wip-us.apache.org/repos/asf/jena/blob/8eeb060c/jena-arq/testing/RIOT/jsonld/graph1.jsonld ---------------------------------------------------------------------- diff --git a/jena-arq/testing/RIOT/jsonld/graph1.jsonld b/jena-arq/testing/RIOT/jsonld/graph1.jsonld index 0f092dc..9b60955 100644 --- a/jena-arq/testing/RIOT/jsonld/graph1.jsonld +++ b/jena-arq/testing/RIOT/jsonld/graph1.jsonld @@ -1,50 +1,62 @@ -[ { - "@id" : "_:b0", - "http://example/r" : [ { - "@value" : "4.5", - "@type" : "http://www.w3.org/2001/XMLSchema#decimal" - } ] -}, { - "@id" : "_:b3" -}, { - "@id" : "http://example/a" -}, { - "@id" : "http://example/s", - "http://example/p" : [ { - "@value" : 2 +{ + "@graph" : [ { + "@id" : "_:b2", + "r" : "4.5" }, { - "@value" : 1 - } ] -}, { - "@id" : "http://example/s1", - "http://example/b" : [ { - "@id" : "http://example/a" - } ] -}, { - "@id" : "http://example/s2", - "http://example/b2" : [ { - "@id" : "_:b3" + "@id" : "http://example/s", + "http://example/p" : [ 2, 1 ] + }, { + "@id" : "http://example/s1", + "b" : "http://example/a" + }, { + "@id" : "http://example/s2", + "b" : "http://example/a", + "b2" : "_:b3" + }, { + "@id" : "http://example/s3", + "b1" : "_:b3" + }, { + "@id" : "http://example/x1", + "http://example/q" : { + "@list" : [ "a", "b" ] + } + }, { + "@id" : "http://example/x2", + "q" : "_:b2" } ], - "http://example/b" : [ { - "@id" : "http://example/a" - } ] -}, { - "@id" : "http://example/s3", - "http://example/b1" : [ { - "@id" : "_:b3" - } ] -}, { - "@id" : "http://example/x1", - "http://example/q" : [ { - "@list" : [ { - "@value" : "a" - }, { - "@value" : "b" - } ] - } ] -}, { - "@id" : "http://example/x2", - "http://example/q" : [ { - "@id" : "_:b0" - } ] -} ] + "@context" : { + "rest" : { + "@id" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#rest", + "@type" : "@id" + }, + "first" : { + "@id" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#first", + "@type" : "http://www.w3.org/2001/XMLSchema#string" + }, + "q" : { + "@id" : "http://example/q", + "@type" : "@id" + }, + "r" : { + "@id" : "http://example/r", + "@type" : "http://www.w3.org/2001/XMLSchema#decimal" + }, + "b2" : { + "@id" : "http://example/b2", + "@type" : "@id" + }, + "b" : { + "@id" : "http://example/b", + "@type" : "@id" + }, + "p" : { + "@id" : "http://example/p", + "@type" : "http://www.w3.org/2001/XMLSchema#integer" + }, + "b1" : { + "@id" : "http://example/b1", + "@type" : "@id" + }, + "xsd" : "http://www.w3.org/2001/XMLSchema#" + } +} http://git-wip-us.apache.org/repos/asf/jena/blob/8eeb060c/jena-arq/testing/RIOT/jsonld/graph2.jsonld ---------------------------------------------------------------------- diff --git a/jena-arq/testing/RIOT/jsonld/graph2.jsonld b/jena-arq/testing/RIOT/jsonld/graph2.jsonld new file mode 100644 index 0000000..60fbd22 --- /dev/null +++ b/jena-arq/testing/RIOT/jsonld/graph2.jsonld @@ -0,0 +1,63 @@ +{ + "@graph" : [ { + "@id" : "_:b1", + "r" : "4.5" + }, { + "@id" : "http://example/s", + "ns:p" : [ 2, 1 ] + }, { + "@id" : "http://example/s1", + "b" : "ns:a" + }, { + "@id" : "http://example/s2", + "b2" : "_:b2", + "b" : "ns:a" + }, { + "@id" : "http://example/s3", + "b1" : "_:b2" + }, { + "@id" : "http://example/x1", + "ns:q" : { + "@list" : [ "a", "b" ] + } + }, { + "@id" : "http://example/x2", + "q" : "_:b1" + } ], + "@context" : { + "rest" : { + "@id" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#rest", + "@type" : "@id" + }, + "first" : { + "@id" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#first", + "@type" : "http://www.w3.org/2001/XMLSchema#string" + }, + "q" : { + "@id" : "http://example/q", + "@type" : "@id" + }, + "b2" : { + "@id" : "http://example/b2", + "@type" : "@id" + }, + "b" : { + "@id" : "http://example/ns#b", + "@type" : "@id" + }, + "r" : { + "@id" : "http://example/r", + "@type" : "http://www.w3.org/2001/XMLSchema#decimal" + }, + "p" : { + "@id" : "http://example/ns#p", + "@type" : "http://www.w3.org/2001/XMLSchema#integer" + }, + "b1" : { + "@id" : "http://example/b1", + "@type" : "@id" + }, + "ns" : "http://example/ns#", + "xsd" : "http://www.w3.org/2001/XMLSchema#" + } +} http://git-wip-us.apache.org/repos/asf/jena/blob/8eeb060c/jena-arq/testing/RIOT/jsonld/graph2.ttl ---------------------------------------------------------------------- diff --git a/jena-arq/testing/RIOT/jsonld/graph2.ttl b/jena-arq/testing/RIOT/jsonld/graph2.ttl new file mode 100644 index 0000000..4a3277c --- /dev/null +++ b/jena-arq/testing/RIOT/jsonld/graph2.ttl @@ -0,0 +1,15 @@ +@prefix : . +@prefix ns: . +@prefix xsd: . + +:s ns:p 1 , 2 . + +:x1 ns:q ("a" "b") . + +:s1 ns:b ns:a . +:s2 ns:b ns:a . + +:s3 :b1 _:aa . +:s2 :b2 _:aa . + +:x2 :q [ :r 4.5 ] .