From 5da3776fbcee79e0159adc9d53ad3ec57aed8399 Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Sun, 17 Feb 2019 15:31:15 -0800 Subject: [PATCH 1/2] Add support for `@type: @none` in term definitions. * Updates value expansion and value compaction, inverse contexts, and term selection. * Causes all value objects which are not compacted away to have their keywords and value of `@type` compacted. --- index.html | 60 +++++++++++++++++++++++++++---- tests/compact-manifest.jsonld | 27 ++++++++++++++ tests/compact/tn01-context.jsonld | 7 ++++ tests/compact/tn01-in.jsonld | 14 ++++++++ tests/compact/tn01-out.jsonld | 19 ++++++++++ tests/compact/tn02-context.jsonld | 7 ++++ tests/compact/tn02-in.jsonld | 3 ++ tests/compact/tn02-out.jsonld | 8 +++++ tests/compact/tn03-context.jsonld | 7 ++++ tests/compact/tn03-in.jsonld | 3 ++ tests/compact/tn03-out.jsonld | 8 +++++ tests/expand-manifest.jsonld | 16 +++++++++ tests/expand/tn01-in.jsonld | 18 ++++++++++ tests/expand/tn02-in.jsonld | 19 ++++++++++ tests/expand/tn02-out.jsonld | 14 ++++++++ 15 files changed, 224 insertions(+), 6 deletions(-) create mode 100644 tests/compact/tn01-context.jsonld create mode 100644 tests/compact/tn01-in.jsonld create mode 100644 tests/compact/tn01-out.jsonld create mode 100644 tests/compact/tn02-context.jsonld create mode 100644 tests/compact/tn02-in.jsonld create mode 100644 tests/compact/tn02-out.jsonld create mode 100644 tests/compact/tn03-context.jsonld create mode 100644 tests/compact/tn03-in.jsonld create mode 100644 tests/compact/tn03-out.jsonld create mode 100644 tests/expand/tn01-in.jsonld create mode 100644 tests/expand/tn02-in.jsonld create mode 100644 tests/expand/tn02-out.jsonld diff --git a/index.html b/index.html index 4d0a5793..2b5268b0 100644 --- a/index.html +++ b/index.html @@ -1246,7 +1246,9 @@

Algorithm

active context, type for value, true for vocab, local context, and defined. If the expanded type is - neither @id, nor @vocab, nor an absolute IRI, an + neither @id, nor @vocab, + nor, if processing mode is json-ld-1.1, @none, + nor an absolute IRI, an invalid type mapping error has been detected and processing is aborted.
  • Set the type mapping for definition to type.
  • @@ -2218,7 +2220,7 @@

    Algorithm

    value.
  • If active property has a type mapping in active context, - other than @id or @vocab, + other than @id or @vocab, or @none, add an @type member to result and set its value to the value associated with the type mapping.
  • @@ -2935,6 +2937,22 @@

    Algorithm

    being processed. +
  • Otherwise, if term definition has a + type mapping which is @null:
  • +
      +
    1. Reference the value associated with the @language + member in type/language map using the variable + language map.
    2. +
    3. If language map does not have an @any + member, create one and set its value to the term + being processed.
    4. +
    5. Reference the value associated with the @type + member in type/language map using the variable + type map.
    6. +
    7. If type map does not have an @any + member, create one and set its value to the term + being processed.
    8. +
  • Otherwise, if term definition has a type mapping:
      @@ -3228,6 +3246,7 @@

      Algorithm

      that order, to preferred values. If value is an empty list object, set type/language to @any. +
    1. Append @any to preferred values.
    2. Initialize term to the result of the Term Selection algorithm, passing inverse context, var, containers, @@ -3558,6 +3577,22 @@

      Algorithm

      1.
    3. If number members is greater than 2, return value as it cannot be compacted.
    4. +
    5. If the type mapping of active property is @none, + leave value as is, as value compaction is disabled. +
        +
      1. Replace any value of @type in value with the result of using the + IRI compaction algorithm, + passing active context, inverse context, + the value of the @type member for var, and + true for vocab.
      2. +
      3. Replace each key in value with the result of using the + IRI compaction algorithm, + passing active context, inverse context, + the that key for var, and + true for vocab.
      4. +
      5. Return value.
      6. +
      +
    6. If value has an @id member:
      1. If number members is 1 and @@ -3590,7 +3625,21 @@

        Algorithm

        or the language mapping of active property is set to null, return the value associated with the @value member.
      2. -
      3. Otherwise, return value as is.
      4. +
      5. Otherwise: +
          +
        1. Replace any value of @type in value with the result of using the + IRI compaction algorithm, + passing active context, inverse context, + the value of the @type member for var, and + true for vocab.
        2. +
        3. Replace each key in value with the result of using the + IRI compaction algorithm, + passing active context, inverse context, + the that key for var, and + true for vocab.
        4. +
        5. Return value.
        6. +
        +
      @@ -5570,11 +5619,9 @@

      Security Considerations

      Open Issues

      The following is a list of issues open at the time of publication.

      -

      Allow @type to have a @container specification, such as @set.

      Define a "streaming profile" for JSON-LD to help parse data from a stream, rather than require the entire document to be in memory. Also to generate documents that can be so streamed. This would aid in using JSON-LD as a dataset dump format where there are a very large number of quads.

      Problems importing contexts which reference other common contexts and result in an error.

      -

      For @graph containers, use the generated graph name identifier as the default subject for nodes in that graph.

      -

      Option to specify level of compaction for literals & resources.

      +

      HTML baseURI and @context?

      @@ -5683,6 +5730,7 @@

      Changes since JSON-LD Community Group Final Report

    7. Added support for sealed contexts and term definitions.
    8. Because scoped contexts can lead to contexts being reloaded, replace the recursive context inclusion error with a context overflow error.
    9. +
    10. Added support for "@type": "@none" in a term definition to prevent value compaction.
    11. diff --git a/tests/compact-manifest.jsonld b/tests/compact-manifest.jsonld index 660249c6..068c69f0 100644 --- a/tests/compact-manifest.jsonld +++ b/tests/compact-manifest.jsonld @@ -1591,6 +1591,33 @@ "context": "compact/li05-context.jsonld", "expect": "compact/li05-out.jsonld", "option": {"specVersion": "json-ld-1.1"} + }, { + "@id": "#ttn01", + "@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"], + "name": "@type: @none does not compact values", + "purpose": "@type: @none does not compact values.", + "option": {"specVersion": "json-ld-1.1"}, + "context": "compact/tn01-context.jsonld", + "input": "compact/tn01-in.jsonld", + "expect": "compact/tn01-out.jsonld" + }, { + "@id": "#ttn02", + "@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"], + "name": "@type: @none does not use arrays by default", + "purpose": "@type: @none honors @container.", + "option": {"specVersion": "json-ld-1.1"}, + "context": "compact/tn02-context.jsonld", + "input": "compact/tn02-in.jsonld", + "expect": "compact/tn02-out.jsonld" + }, { + "@id": "#ttn03", + "@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"], + "name": "@type: @none uses arrays with @container: @set", + "purpose": "@type: @none honors @container.", + "option": {"specVersion": "json-ld-1.1"}, + "context": "compact/tn03-context.jsonld", + "input": "compact/tn03-in.jsonld", + "expect": "compact/tn03-out.jsonld" } ] } diff --git a/tests/compact/tn01-context.jsonld b/tests/compact/tn01-context.jsonld new file mode 100644 index 00000000..4850765e --- /dev/null +++ b/tests/compact/tn01-context.jsonld @@ -0,0 +1,7 @@ +{ + "@context": { + "@version": 1.1, + "xsd": "http://www.w3.org/2001/XMLSchema#", + "notype": {"@id": "http://example.com/notype", "@type": "@none"} + } +} \ No newline at end of file diff --git a/tests/compact/tn01-in.jsonld b/tests/compact/tn01-in.jsonld new file mode 100644 index 00000000..2398cf62 --- /dev/null +++ b/tests/compact/tn01-in.jsonld @@ -0,0 +1,14 @@ +[{ + "http://example.com/notype": [ + {"@value": "string"}, + {"@value": true}, + {"@value": false}, + {"@value": 1}, + {"@value": 10.0}, + {"@value": "plain"}, + {"@value": true, "@type": "http://www.w3.org/2001/XMLSchema#boolean"}, + {"@value": "english", "@language": "en"}, + {"@value": "2018-02-17", "@type": "http://www.w3.org/2001/XMLSchema#date"}, + {"@id": "http://example.com/iri"} + ] +}] \ No newline at end of file diff --git a/tests/compact/tn01-out.jsonld b/tests/compact/tn01-out.jsonld new file mode 100644 index 00000000..bf6b641f --- /dev/null +++ b/tests/compact/tn01-out.jsonld @@ -0,0 +1,19 @@ +{ + "@context": { + "@version": 1.1, + "xsd": "http://www.w3.org/2001/XMLSchema#", + "notype": {"@id": "http://example.com/notype", "@type": "@none"} + }, + "notype": [ + {"@value": "string"}, + {"@value": true}, + {"@value": false}, + {"@value": 1}, + {"@value": 10.0}, + {"@value": "plain"}, + {"@value": true, "@type": "xsd:boolean"}, + {"@value": "english", "@language": "en"}, + {"@value": "2018-02-17", "@type": "xsd:date"}, + {"@id": "http://example.com/iri"} + ] +} \ No newline at end of file diff --git a/tests/compact/tn02-context.jsonld b/tests/compact/tn02-context.jsonld new file mode 100644 index 00000000..4850765e --- /dev/null +++ b/tests/compact/tn02-context.jsonld @@ -0,0 +1,7 @@ +{ + "@context": { + "@version": 1.1, + "xsd": "http://www.w3.org/2001/XMLSchema#", + "notype": {"@id": "http://example.com/notype", "@type": "@none"} + } +} \ No newline at end of file diff --git a/tests/compact/tn02-in.jsonld b/tests/compact/tn02-in.jsonld new file mode 100644 index 00000000..4d2ca634 --- /dev/null +++ b/tests/compact/tn02-in.jsonld @@ -0,0 +1,3 @@ +[{ + "http://example.com/notype": [{"@value": "string"}] +}] \ No newline at end of file diff --git a/tests/compact/tn02-out.jsonld b/tests/compact/tn02-out.jsonld new file mode 100644 index 00000000..cada2038 --- /dev/null +++ b/tests/compact/tn02-out.jsonld @@ -0,0 +1,8 @@ +{ + "@context": { + "@version": 1.1, + "xsd": "http://www.w3.org/2001/XMLSchema#", + "notype": {"@id": "http://example.com/notype", "@type": "@none"} + }, + "notype": {"@value": "string"} +} \ No newline at end of file diff --git a/tests/compact/tn03-context.jsonld b/tests/compact/tn03-context.jsonld new file mode 100644 index 00000000..39d1f8e9 --- /dev/null +++ b/tests/compact/tn03-context.jsonld @@ -0,0 +1,7 @@ +{ + "@context": { + "@version": 1.1, + "xsd": "http://www.w3.org/2001/XMLSchema#", + "notype": {"@id": "http://example.com/notype", "@type": "@none", "@container": "@set"} + } +} \ No newline at end of file diff --git a/tests/compact/tn03-in.jsonld b/tests/compact/tn03-in.jsonld new file mode 100644 index 00000000..4d2ca634 --- /dev/null +++ b/tests/compact/tn03-in.jsonld @@ -0,0 +1,3 @@ +[{ + "http://example.com/notype": [{"@value": "string"}] +}] \ No newline at end of file diff --git a/tests/compact/tn03-out.jsonld b/tests/compact/tn03-out.jsonld new file mode 100644 index 00000000..bfbf9f7c --- /dev/null +++ b/tests/compact/tn03-out.jsonld @@ -0,0 +1,8 @@ +{ + "@context": { + "@version": 1.1, + "xsd": "http://www.w3.org/2001/XMLSchema#", + "notype": {"@id": "http://example.com/notype", "@type": "@none", "@container": "@set"} + }, + "notype": [{"@value": "string"}] +} \ No newline at end of file diff --git a/tests/expand-manifest.jsonld b/tests/expand-manifest.jsonld index 098b620d..ee09b9ad 100644 --- a/tests/expand-manifest.jsonld +++ b/tests/expand-manifest.jsonld @@ -1850,6 +1850,22 @@ "option": {"specVersion": "json-ld-1.1"}, "input": "expand/se09-in.jsonld", "expect": "expand/se09-out.jsonld" + }, { + "@id": "#ttn01", + "@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"], + "name": "@type: @none is illegal in 1.0.", + "purpose": "@type: @none is illegal in json-ld-1.0.", + "option": {"specVersion": "json-ld-1.1"}, + "input": "expand/tn01-in.jsonld", + "expect": "invalid type mapping" + }, { + "@id": "#ttn02", + "@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"], + "name": "@type: @none expands strings as value objects", + "purpose": "@type: @none leaves inputs other than strings alone", + "option": {"specVersion": "json-ld-1.1"}, + "input": "expand/tn02-in.jsonld", + "expect": "expand/tn02-out.jsonld" } ] } diff --git a/tests/expand/tn01-in.jsonld b/tests/expand/tn01-in.jsonld new file mode 100644 index 00000000..5e83158e --- /dev/null +++ b/tests/expand/tn01-in.jsonld @@ -0,0 +1,18 @@ +{ + "@context": { + "xsd": "http://www.w3.org/2001/XMLSchema#", + "notype": {"@id": "http://example.com/notype", "@type": "@none"} + }, + "notype": [ + "string", + true, + false, + 1, + 10.0, + {"@value": "plain"}, + {"@value": true, "@type": "xsd:boolean"}, + {"@value": "english", "@language": "en"}, + {"@value": "2018-02-17", "@type": "xsd:date"}, + {"@id": "http://example.com/iri"} + ] +} \ No newline at end of file diff --git a/tests/expand/tn02-in.jsonld b/tests/expand/tn02-in.jsonld new file mode 100644 index 00000000..79c40761 --- /dev/null +++ b/tests/expand/tn02-in.jsonld @@ -0,0 +1,19 @@ +{ + "@context": { + "@version": 1.1, + "xsd": "http://www.w3.org/2001/XMLSchema#", + "notype": {"@id": "http://example.com/notype", "@type": "@none"} + }, + "notype": [ + "string", + true, + false, + 1, + 10.0, + {"@value": "plain"}, + {"@value": true, "@type": "xsd:boolean"}, + {"@value": "english", "@language": "en"}, + {"@value": "2018-02-17", "@type": "xsd:date"}, + {"@id": "http://example.com/iri"} + ] +} \ No newline at end of file diff --git a/tests/expand/tn02-out.jsonld b/tests/expand/tn02-out.jsonld new file mode 100644 index 00000000..2398cf62 --- /dev/null +++ b/tests/expand/tn02-out.jsonld @@ -0,0 +1,14 @@ +[{ + "http://example.com/notype": [ + {"@value": "string"}, + {"@value": true}, + {"@value": false}, + {"@value": 1}, + {"@value": 10.0}, + {"@value": "plain"}, + {"@value": true, "@type": "http://www.w3.org/2001/XMLSchema#boolean"}, + {"@value": "english", "@language": "en"}, + {"@value": "2018-02-17", "@type": "http://www.w3.org/2001/XMLSchema#date"}, + {"@id": "http://example.com/iri"} + ] +}] \ No newline at end of file From 6a2dd3836863f8e6077b5a522161ae1a4b0680c3 Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Mon, 18 Feb 2019 12:06:52 -0800 Subject: [PATCH 2/2] `@null` => `@none`. --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 2b5268b0..8247c6a1 100644 --- a/index.html +++ b/index.html @@ -2938,7 +2938,7 @@

      Algorithm

  • Otherwise, if term definition has a - type mapping which is @null:
  • + type mapping which is @none:
    1. Reference the value associated with the @language member in type/language map using the variable