Ensure that annotations are preserved if not compacted to an annotation map
authorMarkus Lanthaler <mark_lanthaler@gmx.net>
Sun, 09 Dec 2012 19:22:17 +0100
changeset 1014 966933d6e7c3
parent 1013 b51f1be1131f
child 1015 c30639ca3161
Ensure that annotations are preserved if not compacted to an annotation map

This addresses #196.
test-suite/tests/compact-0030-context.jsonld
test-suite/tests/compact-0030-in.jsonld
test-suite/tests/compact-0030-out.jsonld
test-suite/tests/compact-manifest.jsonld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/compact-0030-context.jsonld	Sun Dec 09 19:22:17 2012 +0100
@@ -0,0 +1,6 @@
+{
+  "@context": {
+    "property": "http://example.com/property",
+    "annotContainer": { "@id": "http://example.com/container", "@container": "@annotation" }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/compact-0030-in.jsonld	Sun Dec 09 19:22:17 2012 +0100
@@ -0,0 +1,117 @@
+[
+   {
+      "@id": "http://example.org/annotationsTest",
+      "http://example.com/container": [
+         {
+            "@id": "http://example.org/nodeWithoutAnnotationA",
+            "@annotation": "A"
+         },
+         {
+            "@id": "http://example.org/nodeWithAnnotationA",
+            "@annotation": "this overrides the 'A' annotation from the container"
+         },
+         {
+            "@value": 1,
+            "@annotation": "A"
+         },
+         {
+            "@value": true,
+            "@annotation": "A"
+         },
+         {
+            "@value": false,
+            "@annotation": "A"
+         },
+         {
+            "@value": "simple string A",
+            "@annotation": "A"
+         },
+         {
+            "@value": "typed literal A",
+            "@type": "http://example.org/type",
+            "@annotation": "A"
+         },
+         {
+            "@value": "language-tagged string A",
+            "@language": "en",
+            "@annotation": "A"
+         },
+         {
+            "@value": "simple string B",
+            "@annotation": "B"
+         },
+         {
+            "@id": "http://example.org/nodeWithoutAnnotationC",
+            "@annotation": "C"
+         },
+         {
+            "@id": "http://example.org/nodeWithAnnotationC",
+            "@annotation": "this overrides the 'C' annotation from the container"
+         },
+         {
+            "@value": 3,
+            "@annotation": "C"
+         },
+         {
+            "@value": true,
+            "@annotation": "C"
+         },
+         {
+            "@value": false,
+            "@annotation": "C"
+         },
+         {
+            "@value": "simple string C",
+            "@annotation": "C"
+         },
+         {
+            "@value": "typed literal C",
+            "@type": "http://example.org/type",
+            "@annotation": "C"
+         },
+         {
+            "@value": "language-tagged string C",
+            "@language": "en",
+            "@annotation": "C"
+         }
+      ],
+      "http://example.com/property": [
+         {
+            "@id": "http://example.org/nodeWithoutAnnotationProp"
+         },
+         {
+            "@id": "http://example.org/nodeWithAnnotationProp",
+            "@annotation": "prop"
+         },
+         {
+            "@value": 3,
+            "@annotation": "prop"
+         },
+         {
+            "@value": true,
+            "@annotation": "prop"
+         },
+         {
+            "@value": false,
+            "@annotation": "prop"
+         },
+         {
+            "@value": "simple string no annotation"
+         },
+         {
+            "@value": "typed literal Prop",
+            "@type": "http://example.org/type",
+            "@annotation": "prop"
+         },
+         {
+            "@value": "language-tagged string Prop",
+            "@language": "en",
+            "@annotation": "prop"
+         },
+         {
+             "@value": "annotation using an array with just one element (automatic recovery)",
+             "@annotation": "prop"
+         }
+      ]
+   }
+]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/compact-0030-out.jsonld	Sun Dec 09 19:22:17 2012 +0100
@@ -0,0 +1,86 @@
+{
+  "@context": {
+    "property": "http://example.com/property",
+    "annotContainer": { "@id": "http://example.com/container", "@container": "@annotation" }
+  },
+  "@id": "http://example.org/annotationsTest",
+  "annotContainer": {
+    "A": [
+      {
+        "@id": "http://example.org/nodeWithoutAnnotationA"
+      },
+      1,
+      true,
+      false,
+      "simple string A",
+      {
+        "@value": "typed literal A",
+        "@type": "http://example.org/type"
+      },
+      {
+        "@value": "language-tagged string A",
+        "@language": "en"
+      }
+    ],
+    "this overrides the 'A' annotation from the container": {
+      "@id": "http://example.org/nodeWithAnnotationA"
+    },
+    "B": "simple string B",
+    "C": [
+      {
+        "@id": "http://example.org/nodeWithoutAnnotationC"
+      },
+      3,
+      true,
+      false,
+      "simple string C",
+      {
+        "@value": "typed literal C",
+        "@type": "http://example.org/type"
+      },
+      {
+        "@value": "language-tagged string C",
+        "@language": "en"
+      }
+    ],
+    "this overrides the 'C' annotation from the container": {
+      "@id": "http://example.org/nodeWithAnnotationC"
+    }
+  },
+  "property": [
+    {
+      "@id": "http://example.org/nodeWithoutAnnotationProp"
+    },
+    {
+      "@id": "http://example.org/nodeWithAnnotationProp",
+      "@annotation": "prop"
+    },
+    {
+      "@value": 3,
+      "@annotation": "prop"
+    },
+    {
+      "@value": true,
+      "@annotation": "prop"
+    },
+    {
+      "@value": false,
+      "@annotation": "prop"
+    },
+    "simple string no annotation",
+    {
+      "@value": "typed literal Prop",
+      "@type": "http://example.org/type",
+      "@annotation": "prop"
+    },
+    {
+      "@value": "language-tagged string Prop",
+      "@language": "en",
+      "@annotation": "prop"
+    },
+    {
+      "@value": "annotation using an array with just one element (automatic recovery)",
+      "@annotation": "prop"
+    }
+  ]
+}
--- a/test-suite/tests/compact-manifest.jsonld	Sun Dec 09 19:14:42 2012 +0100
+++ b/test-suite/tests/compact-manifest.jsonld	Sun Dec 09 19:22:17 2012 +0100
@@ -180,5 +180,11 @@
     "input": "compact-0029-in.jsonld",
     "context": "compact-0029-context.jsonld",
     "expect": "compact-0029-out.jsonld"
+  }, {
+    "@type": ["test:TestCase", "jld:CompactTest"],
+    "name": "Preserve @annotation tags if not compacted to an annotation map",
+    "input": "compact-0030-in.jsonld",
+    "context": "compact-0030-context.jsonld",
+    "expect": "compact-0030-out.jsonld"
   }]
 }