From 80a5565b87636ff5d95aa840d97d84c4633150b5 Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Mon, 1 Oct 2018 12:26:15 -0700 Subject: [PATCH 1/2] Algorithm updates and tests to allow `@container: @set` on @type or an alias in 1.1. Remains an error to redefine `@type` in 1.0. For w3c/json-ld-syntax#34. --- index.html | 59 +++++++++++++++++-------------- tests/compact-manifest.jsonld | 27 ++++++++++++++ tests/compact/0104-context.jsonld | 5 +++ tests/compact/0104-in.jsonld | 3 ++ tests/compact/0104-out.jsonld | 6 ++++ tests/compact/0105-context.jsonld | 5 +++ tests/compact/0105-in.jsonld | 3 ++ tests/compact/0105-out.jsonld | 6 ++++ tests/compact/0106-context.jsonld | 5 +++ tests/compact/0106-in.jsonld | 3 ++ tests/compact/0106-out.jsonld | 6 ++++ tests/expand-manifest.jsonld | 7 ++++ tests/expand/e042-in.jsonld | 6 ++++ 13 files changed, 115 insertions(+), 26 deletions(-) create mode 100644 tests/compact/0104-context.jsonld create mode 100644 tests/compact/0104-in.jsonld create mode 100644 tests/compact/0104-out.jsonld create mode 100644 tests/compact/0105-context.jsonld create mode 100644 tests/compact/0105-in.jsonld create mode 100644 tests/compact/0105-out.jsonld create mode 100644 tests/compact/0106-context.jsonld create mode 100644 tests/compact/0106-in.jsonld create mode 100644 tests/compact/0106-out.jsonld create mode 100644 tests/expand/e042-in.jsonld diff --git a/index.html b/index.html index fc02839b..4737b4b7 100644 --- a/index.html +++ b/index.html @@ -1125,7 +1125,7 @@

Create Term Definition

Overview

-

term definitions are created by +

Term definitions are created by parsing the information in the given local context for the given term. If the given term is a compact IRI, it may omit an IRI mapping by @@ -1165,14 +1165,21 @@

Algorithm

  • Set the value associated with defined's term member to false. This indicates that the term definition is now being created but is not yet complete.
  • -
  • Since keywords cannot be overridden, - term must not be a keyword. Otherwise, a +
  • Initialize value to a copy of the value associated with the member + term in local context.
  • +
  • If processingMode + is json-ld-1.1 + and term is @type, value + MUST be a dictionary with the member @container + and value @set. Any other value means that a + keyword redefinition error has + been detected and processing is aborted.
  • +
  • Otherwise, since keywords cannot be overridden, + term MUST NOT be a keyword and a keyword redefinition error has been detected and processing is aborted.
  • Remove any existing term definition for term in active context.
  • -
  • Initialize value to a copy of the value associated with the member - term in local context.
  • If value is null or value is a dictionary containing the key-value pair @id-null, set the @@ -1183,7 +1190,7 @@

    Algorithm

    to a dictionary consisting of a single member whose key is @id and whose value is value. Set simple term to true.
  • -
  • Otherwise, value must be a dictionary, if not, an +
  • Otherwise, value MUST be a dictionary, if not, an invalid term definition error has been detected and processing is aborted. Set simple term to false.
  • @@ -1191,7 +1198,7 @@

    Algorithm

  • If value contains the member @type:
    1. Initialize type to the value associated with the - @type member, which must be a string. Otherwise, an + @type member, which MUST be a string. Otherwise, an invalid type mapping error has been detected and processing is aborted.
    2. Set type to the result of using the @@ -1283,6 +1290,8 @@

      Algorithm

      of definition to term.
  • +
  • Otherwise, if term is @type, set the IRI mapping + of definition to @type.
  • Otherwise, if active context has a vocabulary mapping, the IRI mapping of definition is set to the result of concatenating the value @@ -1293,7 +1302,7 @@

    Algorithm

  • If value contains the member @container:
    1. Initialize container to the value associated with the - @container member, which must be either + @container member, which MUST be either @graph, @id, @index, @@ -1341,7 +1350,7 @@

      Algorithm

      does not contain the member @type:
      1. Initialize language to the value associated with the - @language member, which must be either null + @language member, which MUST be either null or a string. Otherwise, an invalid language mapping error has been detected and processing is aborted.
      2. @@ -1356,8 +1365,8 @@

        Algorithm

        invalid term definition has been detected and processing is aborted.
      3. Initialize nest value in definition to the value associated with the - @nest member, which must be a string and - must not be a keyword other than @nest. Otherwise, an + @nest member, which MUST be a string and + MUST NOT be a keyword other than @nest. Otherwise, an invalid @nest value error has been detected and processing is aborted.
      @@ -1369,7 +1378,7 @@

      Algorithm

      invalid term definition has been detected and processing is aborted.
    2. Initialize the prefix flag to the value associated with the - @prefix member, which must be a boolean. Otherwise, an + @prefix member, which MUST be a boolean. Otherwise, an invalid @prefix value error has been detected and processing is aborted.
    @@ -2398,6 +2407,12 @@

    Algorithm

    passing active context, inverse context, expanded property for var, and true for vocab.
  • +
  • If processing mode is json-ld-1.1, + element does not have an @value member, + expanded property is @type, + and the term definition for alias in the + active context has a container mapping including @set, + ensure that compacted value is an array.
  • Add a member alias to result whose value is set to compacted value and continue to the next expanded property.
  • @@ -2417,7 +2432,7 @@

    Algorithm

  • If the term definition for property in the active context indicates that property is a reverse property -
      +
      1. If the term definition for property in the active context has a container mapping including @set or @@ -5457,20 +5472,8 @@

        Changes since 1.0 Recommendation of 16 January 2014

        a context. When this is set, vocabulary-relative IRIs, such as the members of node objects, are expanded or compacted relative to the base IRI using string concatenation.
      2. -
      3. Lists may now have members which are themselves lists.
      4. -
      5. The Deserialize JSON-LD to RDF Algorithm - has been updated to ensure that only well-formed triples - are emitted; previously, it only ensured that triples containing - relative IRIs were excluded.
      6. -
      7. The API now adds an ordered - option, defaulting to false This is used in algorithms to - control interation of dictionary member keys. Previously, the - algorithms always required such an order. The instructions for - evaluating test results have been updated accordingly.
      8. -
      9. The Generate Blank Node Identifier algorithm - has been updated to remove the specifics of how new blank node - identifiers are created.
      10. +

        Additionally, see .

  • @@ -5489,6 +5492,10 @@

    Changes since JSON-LD Community Group Final Report

  • The Generate Blank Node Identifier algorithm has been updated to remove the specifics of how new blank node identifiers are created.
  • +
  • Values of @type, or an alais of @type, may now have their @container set to @set + to ensure that @type members are always represented as an array. This + also allows a term to be defined for @type, where the value MUST be a dictionary + with @container set to @set.
  • diff --git a/tests/compact-manifest.jsonld b/tests/compact-manifest.jsonld index d7b1b683..666580d5 100644 --- a/tests/compact-manifest.jsonld +++ b/tests/compact-manifest.jsonld @@ -869,6 +869,33 @@ "context": "compact/0103-context.jsonld", "expect": "compact/0103-out.jsonld", "option": {"processingMode": "json-ld-1.1", "specVersion": "json-ld-1.1"} + }, { + "@id": "#t0104", + "@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"], + "name": "Compact @type with @container: @set", + "purpose": "Ensures that a single @type value is represented as an array", + "input": "compact/0104-in.jsonld", + "context": "compact/0104-context.jsonld", + "expect": "compact/0104-out.jsonld", + "option": {"processingMode": "json-ld-1.1", "specVersion": "json-ld-1.1"} + }, { + "@id": "#t0105", + "@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"], + "name": "Compact @type with @container: @set using an alias of @type", + "purpose": "Ensures that a single @type value is represented as an array", + "input": "compact/0105-in.jsonld", + "context": "compact/0105-context.jsonld", + "expect": "compact/0105-out.jsonld", + "option": {"processingMode": "json-ld-1.1", "specVersion": "json-ld-1.1"} + }, { + "@id": "#t0106", + "@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"], + "name": "Do not compact @type with @container: @set to an array using an alias of @type", + "purpose": "Ensures that a single @type value is not represented as an array in 1.0", + "input": "compact/0106-in.jsonld", + "context": "compact/0106-context.jsonld", + "expect": "compact/0106-out.jsonld", + "option": {"processingMode": "json-ld-1.0", "specVersion": "json-ld-1.1"} }, { "@id": "#tc001", "@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"], diff --git a/tests/compact/0104-context.jsonld b/tests/compact/0104-context.jsonld new file mode 100644 index 00000000..36d7203c --- /dev/null +++ b/tests/compact/0104-context.jsonld @@ -0,0 +1,5 @@ +{ + "@context": { + "@type": {"@container": "@set"} + } +} \ No newline at end of file diff --git a/tests/compact/0104-in.jsonld b/tests/compact/0104-in.jsonld new file mode 100644 index 00000000..9bcd4848 --- /dev/null +++ b/tests/compact/0104-in.jsonld @@ -0,0 +1,3 @@ +{ + "@type": "http://example.org/type" +} diff --git a/tests/compact/0104-out.jsonld b/tests/compact/0104-out.jsonld new file mode 100644 index 00000000..8699cfa7 --- /dev/null +++ b/tests/compact/0104-out.jsonld @@ -0,0 +1,6 @@ +{ + "@context": { + "@type": {"@container": "@set"} + }, + "@type": ["http://example.org/type"] +} \ No newline at end of file diff --git a/tests/compact/0105-context.jsonld b/tests/compact/0105-context.jsonld new file mode 100644 index 00000000..5031f856 --- /dev/null +++ b/tests/compact/0105-context.jsonld @@ -0,0 +1,5 @@ +{ + "@context": { + "type": {"@id": "@type", "@container": "@set"} + } +} \ No newline at end of file diff --git a/tests/compact/0105-in.jsonld b/tests/compact/0105-in.jsonld new file mode 100644 index 00000000..9bcd4848 --- /dev/null +++ b/tests/compact/0105-in.jsonld @@ -0,0 +1,3 @@ +{ + "@type": "http://example.org/type" +} diff --git a/tests/compact/0105-out.jsonld b/tests/compact/0105-out.jsonld new file mode 100644 index 00000000..5595923a --- /dev/null +++ b/tests/compact/0105-out.jsonld @@ -0,0 +1,6 @@ +{ + "@context": { + "type": {"@id": "@type", "@container": "@set"} + }, + "type": ["http://example.org/type"] +} \ No newline at end of file diff --git a/tests/compact/0106-context.jsonld b/tests/compact/0106-context.jsonld new file mode 100644 index 00000000..5031f856 --- /dev/null +++ b/tests/compact/0106-context.jsonld @@ -0,0 +1,5 @@ +{ + "@context": { + "type": {"@id": "@type", "@container": "@set"} + } +} \ No newline at end of file diff --git a/tests/compact/0106-in.jsonld b/tests/compact/0106-in.jsonld new file mode 100644 index 00000000..9bcd4848 --- /dev/null +++ b/tests/compact/0106-in.jsonld @@ -0,0 +1,3 @@ +{ + "@type": "http://example.org/type" +} diff --git a/tests/compact/0106-out.jsonld b/tests/compact/0106-out.jsonld new file mode 100644 index 00000000..84326c5c --- /dev/null +++ b/tests/compact/0106-out.jsonld @@ -0,0 +1,6 @@ +{ + "@context": { + "type": {"@id": "@type", "@container": "@set"} + }, + "type": "http://example.org/type" +} \ No newline at end of file diff --git a/tests/expand-manifest.jsonld b/tests/expand-manifest.jsonld index cad05d00..350aa160 100644 --- a/tests/expand-manifest.jsonld +++ b/tests/expand-manifest.jsonld @@ -1180,6 +1180,13 @@ "purpose": "Verifies that an exception is raised in Expansion when an invalid set or list object is found", "input": "expand/e041-in.jsonld", "expect": "invalid set or list object" + }, { + "@id": "#te042", + "@type": [ "jld:NegativeEvaluationTest", "jld:ExpandTest" ], + "name": "Keywords may not be redefined", + "purpose": "Verifies that an exception is raised on expansion when processing an invalid context attempting to define @container on a keyword", + "input": "expand/e042-in.jsonld", + "expect": "keyword redefinition" }, { "@id": "#tec01", "@type": [ "jld:NegativeEvaluationTest", "jld:ExpandTest" ], diff --git a/tests/expand/e042-in.jsonld b/tests/expand/e042-in.jsonld new file mode 100644 index 00000000..41360255 --- /dev/null +++ b/tests/expand/e042-in.jsonld @@ -0,0 +1,6 @@ +{ + "@context": { + "@type": {"@container": "@set"} + }, + "@type": "http://example.org/type" +} From 487c4fcfe8335f2c6c251a83e687a033ffeb82f2 Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Mon, 1 Oct 2018 17:37:48 -0700 Subject: [PATCH 2/2] Add code modifier to `@set`. --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 4737b4b7..2ce4ae5c 100644 --- a/index.html +++ b/index.html @@ -5492,7 +5492,7 @@

    Changes since JSON-LD Community Group Final Report

  • The Generate Blank Node Identifier algorithm has been updated to remove the specifics of how new blank node identifiers are created.
  • -
  • Values of @type, or an alais of @type, may now have their @container set to @set +
  • Values of @type, or an alais of @type, may now have their @container set to @set to ensure that @type members are always represented as an array. This also allows a term to be defined for @type, where the value MUST be a dictionary with @container set to @set.