jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cla...@apache.org
Subject [12/50] [abbrv] jena git commit: JENA-934: Skip a prefix of the empty string - not allowed in JSON-LD
Date Sat, 16 May 2015 08:58:54 GMT
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 <andy@apache.org>
Authored: Tue May 5 18:39:57 2015 +0100
Committer: Andy Seaborne <andy@apache.org>
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<String, IRI> pmap = prefixMap.getMapping() ;
         for ( Entry<String, IRI> 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 : <http://example/> .
+@prefix ns: <http://example/ns#> .
+@prefix xsd:     <http://www.w3.org/2001/XMLSchema#> .
+
+: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 ] .


Mime
View raw message