When compacting an IRI, if the IRI can't be compacted, and the IRI itself is mapped to null, return null.
This addresses issue #56.
--- a/spec/latest/json-ld-api/index.html Fri Apr 27 16:22:34 2012 -0400
+++ b/spec/latest/json-ld-api/index.html Fri Apr 27 13:40:58 2012 -0700
@@ -1168,7 +1168,9 @@
<tref>term</tref> associated with the partially
matched IRI in the <tref>active context</tref> concatenated with a
colon (:) character and the unmatched part of <em>iri</em>.</li>
- <li>If <em>terms</em> is empty, return <em>iri</em>.</li>
+ <li>If <em>terms</em> is empty, and <em>iri</em> has a mapping to <tref>null</tref>,
+ return <tref>null</tref>.</li>
+ <li>Otherwise if <em>terms</em> is empty, add <em>iri</em> to <em>terms</em>.</li>
<li>Return the shortest and lexicographically least value in <em>terms</em>.</li>
</ol>
</p>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/compact-0017-context.jsonld Fri Apr 27 13:40:58 2012 -0700
@@ -0,0 +1,6 @@
+{
+ "@context": {
+ "http://www.w3.org/2000/01/rdf-schema#comment": null,
+ "comment_en": {"@id": "http://www.w3.org/2000/01/rdf-schema#comment", "@language": "en"}
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/compact-0017-in.jsonld Fri Apr 27 13:40:58 2012 -0700
@@ -0,0 +1,6 @@
+{
+ "http://www.w3.org/2000/01/rdf-schema#comment": [
+ {"@value": "Kommenten auf Deutch.","@language": "de"},
+ {"@value": "Comment in English.","@language": "en"}
+ ]
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/compact-0017-out.jsonld Fri Apr 27 13:40:58 2012 -0700
@@ -0,0 +1,7 @@
+{
+ "@context": {
+ "http://www.w3.org/2000/01/rdf-schema#comment": null,
+ "comment_en": {"@id": "http://www.w3.org/2000/01/rdf-schema#comment", "@language": "en"}
+ },
+ "comment_en": "Comment in English."
+}
--- a/test-suite/tests/compact-manifest.jsonld Fri Apr 27 16:22:34 2012 -0400
+++ b/test-suite/tests/compact-manifest.jsonld Fri Apr 27 13:40:58 2012 -0700
@@ -101,5 +101,11 @@
"input": "compact-0016-in.jsonld",
"context": "compact-0016-context.jsonld",
"expect": "compact-0016-out.jsonld"
+ }, {
+ "@type": ["test:TestCase", "jld:CompactTest"],
+ "name": "Absolute IRI mapped to null is removed from output, except if it is used in a term",
+ "input": "compact-0017-in.jsonld",
+ "context": "compact-0017-context.jsonld",
+ "expect": "compact-0017-out.jsonld"
}]
}