From 91d1266b6627d5b3760ecd4d0db2022ad2541dea Mon Sep 17 00:00:00 2001 From: "David I. Lehn" Date: Thu, 12 Mar 2020 22:12:57 -0400 Subject: [PATCH 1/6] Add context recursion tests. - 1.0 expand: - e003 looked like e002. Made it use a level of indirection. - 1.1 expand: - Copy e002 and e003 to e052 and e053 and use newer "context overflow" code. - Add e054 cross linked sibling contexts test. - Add 0124, 0125, 0126 scoped context recursion tests. --- tests/expand/0124-context.jsonld | 12 ++++++++++++ tests/expand/0125-context-1.jsonld | 12 ++++++++++++ tests/expand/0125-context-2.jsonld | 3 +++ tests/expand/0126-context-1.jsonld | 3 +++ tests/expand/0126-context-2.jsonld | 3 +++ tests/expand/0126-context-3.jsonld | 12 ++++++++++++ tests/expand/0126-in.jsonld | 10 ++++++++++ tests/expand/0126-out.jsonld | 14 ++++++++++++++ tests/expand/e003-context.jsonld | 3 +++ tests/expand/e052-in.jsonld | 4 ++++ tests/expand/e053-context.jsonld | 3 +++ tests/expand/e053-in.jsonld | 4 ++++ tests/expand/e054-context-1.jsonld | 3 +++ tests/expand/e054-context-2.jsonld | 3 +++ tests/expand/e054-in.jsonld | 7 +++++++ 15 files changed, 96 insertions(+) create mode 100644 tests/expand/0124-context.jsonld create mode 100644 tests/expand/0125-context-1.jsonld create mode 100644 tests/expand/0125-context-2.jsonld create mode 100644 tests/expand/0126-context-1.jsonld create mode 100644 tests/expand/0126-context-2.jsonld create mode 100644 tests/expand/0126-context-3.jsonld create mode 100644 tests/expand/0126-in.jsonld create mode 100644 tests/expand/0126-out.jsonld create mode 100644 tests/expand/e003-context.jsonld create mode 100644 tests/expand/e052-in.jsonld create mode 100644 tests/expand/e053-context.jsonld create mode 100644 tests/expand/e053-in.jsonld create mode 100644 tests/expand/e054-context-1.jsonld create mode 100644 tests/expand/e054-context-2.jsonld create mode 100644 tests/expand/e054-in.jsonld diff --git a/tests/expand/0124-context.jsonld b/tests/expand/0124-context.jsonld new file mode 100644 index 00000000..165ec43b --- /dev/null +++ b/tests/expand/0124-context.jsonld @@ -0,0 +1,12 @@ +{ + "@context": { + "@version": 1.1, + "prop": { + "@id": "ex:prop", + "@context": "0124-context.jsonld" + }, + "value": { + "@id": "ex:value" + } + } +} diff --git a/tests/expand/0125-context-1.jsonld b/tests/expand/0125-context-1.jsonld new file mode 100644 index 00000000..10f09041 --- /dev/null +++ b/tests/expand/0125-context-1.jsonld @@ -0,0 +1,12 @@ +{ + "@context": { + "@version": 1.1, + "prop": { + "@id": "ex:prop", + "@context": "0125-context-2.jsonld" + }, + "value": { + "@id": "ex:value" + } + } +} diff --git a/tests/expand/0125-context-2.jsonld b/tests/expand/0125-context-2.jsonld new file mode 100644 index 00000000..8d63a813 --- /dev/null +++ b/tests/expand/0125-context-2.jsonld @@ -0,0 +1,3 @@ +{ + "@context": "0125-context-1.jsonld" +} diff --git a/tests/expand/0126-context-1.jsonld b/tests/expand/0126-context-1.jsonld new file mode 100644 index 00000000..4c695ba2 --- /dev/null +++ b/tests/expand/0126-context-1.jsonld @@ -0,0 +1,3 @@ +{ + "@context": "0126-context-3.jsonld" +} diff --git a/tests/expand/0126-context-2.jsonld b/tests/expand/0126-context-2.jsonld new file mode 100644 index 00000000..4c695ba2 --- /dev/null +++ b/tests/expand/0126-context-2.jsonld @@ -0,0 +1,3 @@ +{ + "@context": "0126-context-3.jsonld" +} diff --git a/tests/expand/0126-context-3.jsonld b/tests/expand/0126-context-3.jsonld new file mode 100644 index 00000000..4e152051 --- /dev/null +++ b/tests/expand/0126-context-3.jsonld @@ -0,0 +1,12 @@ +{ + "@context": { + "@version": 1.1, + "prop": { + "@id": "ex:prop", + "@context": "0126-context-3.jsonld" + }, + "value": { + "@id": "ex:value" + } + } +} diff --git a/tests/expand/0126-in.jsonld b/tests/expand/0126-in.jsonld new file mode 100644 index 00000000..b98a4e1f --- /dev/null +++ b/tests/expand/0126-in.jsonld @@ -0,0 +1,10 @@ +{ + "@context": [ + "0126-context-1.jsonld", + "0126-context-2.jsonld" + ], + "@id": "ex:id", + "prop": { + "value": "v" + } +} diff --git a/tests/expand/0126-out.jsonld b/tests/expand/0126-out.jsonld new file mode 100644 index 00000000..bdf762a6 --- /dev/null +++ b/tests/expand/0126-out.jsonld @@ -0,0 +1,14 @@ +[ + { + "@id": "ex:id", + "ex:prop": [ + { + "ex:value": [ + { + "@value": "v" + } + ] + } + ] + } +] diff --git a/tests/expand/e003-context.jsonld b/tests/expand/e003-context.jsonld new file mode 100644 index 00000000..8629f916 --- /dev/null +++ b/tests/expand/e003-context.jsonld @@ -0,0 +1,3 @@ +{ + "@context": "e003-in.jsonld" +} diff --git a/tests/expand/e052-in.jsonld b/tests/expand/e052-in.jsonld new file mode 100644 index 00000000..7e3013c5 --- /dev/null +++ b/tests/expand/e052-in.jsonld @@ -0,0 +1,4 @@ +{ + "@context": "e052-in.jsonld", + "@id": "http://example/test#example" +} diff --git a/tests/expand/e053-context.jsonld b/tests/expand/e053-context.jsonld new file mode 100644 index 00000000..2da63c09 --- /dev/null +++ b/tests/expand/e053-context.jsonld @@ -0,0 +1,3 @@ +{ + "@context": "e053-in.jsonld" +} diff --git a/tests/expand/e053-in.jsonld b/tests/expand/e053-in.jsonld new file mode 100644 index 00000000..5f672792 --- /dev/null +++ b/tests/expand/e053-in.jsonld @@ -0,0 +1,4 @@ +{ + "@context": "e053-context.jsonld", + "@id": "http://example/test#example" +} diff --git a/tests/expand/e054-context-1.jsonld b/tests/expand/e054-context-1.jsonld new file mode 100644 index 00000000..5f536da4 --- /dev/null +++ b/tests/expand/e054-context-1.jsonld @@ -0,0 +1,3 @@ +{ + "@context": "e054-context-2.jsonld" +} diff --git a/tests/expand/e054-context-2.jsonld b/tests/expand/e054-context-2.jsonld new file mode 100644 index 00000000..16c05b52 --- /dev/null +++ b/tests/expand/e054-context-2.jsonld @@ -0,0 +1,3 @@ +{ + "@context": "e054-context-1.jsonld" +} diff --git a/tests/expand/e054-in.jsonld b/tests/expand/e054-in.jsonld new file mode 100644 index 00000000..e3ac866e --- /dev/null +++ b/tests/expand/e054-in.jsonld @@ -0,0 +1,7 @@ +{ + "@context": [ + "e054-context-1.jsonld", + "e054-context-2.jsonld" + ], + "@id": "ex:id" +} From 49be5749942bd0e7db518ec494003d88b546cad7 Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Sun, 15 Mar 2020 14:23:00 -0700 Subject: [PATCH 2/6] Add _validate scoped context_ argument to Create Term Definition and Context Processing algorithms used to limit recursive context processing when validating scoped contexts. --- index.html | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/index.html b/index.html index caf3f8d5..eef01120 100644 --- a/index.html +++ b/index.html @@ -1192,7 +1192,7 @@

Algorithm

This algorithm specifies how a new active context is updated with a local context. The algorithm takes three required - and three optional + and four optional input variables. The required inputs are an active context, @@ -1204,8 +1204,10 @@

Algorithm

override protected, defaulting to false, which is used to allow changes to protected terms, - and propagate, defaulting to true - to mark term definitions associated with non-propagated contexts.. + propagate, defaulting to true + to mark term definitions associated with non-propagated contexts, + and validate scoped context defaulting to true, + which is used to limit recursion when validating possibly recusive scoped contexts..

    @@ -1290,6 +1292,9 @@

    Algorithm

  1. Set loaded context to the value of that entry.
+
  • If validate scoped context is false, + do not process loaded context and continue to any next + context in local context.
  • Set result to the result of recursively calling this algorithm, passing result for active context, loaded context for local context, @@ -1470,9 +1475,10 @@

    Algorithm

    defined, base URL, - and the value of the @protected - entry from context, if any, for protected - . + the value of the @protected + entry from context, if any, for protected, + and validate scoped context. +
  • @@ -1519,7 +1525,7 @@

    Overview

    Algorithm

    -

    The algorithm has four required and three optional inputs. +

    The algorithm has four required and four optional inputs. The required inputs are an active context, a local context, @@ -1529,7 +1535,9 @@

    Algorithm

    base URL defaulting to null, protected which defaults to false, and override protected, defaulting to false, - which is used to allow changes to protected terms.. + which is used to allow changes to protected terms, + and validate scoped context defaulting to true, + which is used to limit recursion when validating possibly recusive scoped contexts..

    1. If defined contains the entry term and the associated @@ -1805,7 +1813,8 @@

      Algorithm

    2. Invoke the Context Processing algorithm using the active context, context as local context, base URL, - and true for override protected. + true for override protected, + and false for validate scoped context. If any error is detected, an invalid scoped context error has been detected and processing is aborted. @@ -6641,7 +6650,7 @@

      JsonLdErrorCode

      conflicting indexes
      Multiple conflicting indexes have been found for the same node.
      context overflow
      -
      maximum number of @context URLs exceeded.
      +
      Maximum number of @context URLs exceeded.
      cyclic IRI mapping
      A cycle in IRI mappings has been detected.
      invalid @id value
      @@ -6985,7 +6994,7 @@

      Changes since Candidate Release of 05 March 2020

      within an active context, and initialized as necessary. This simplifies calling sequences and better represents actual implementation experience.
    3. Update step 12.8.9.6
    4. -
    5. Update step 12.8.1 of the +
    6. Update step 12.8.10 of the Compaction Algorithm to add values to nest result instead of result as was originally intended.
    7. @@ -6993,6 +7002,14 @@

      Changes since Candidate Release of 05 March 2020

      of to exclude `@type`, leaving it to the next step. This could cause type values from a node to be left out of the merge. +
    8. Added step 5.2.5 + to the Context Processing algorithm, + which is added validate scoped context as a new + optional argument, and passed to the + Create Term Definition algorithm, + which in turn uses it with the value `false` when recursively calling + the Context Processing algorithm + when validating a scoped context.
    Date: Sun, 15 Mar 2020 14:37:35 -0700 Subject: [PATCH 3/6] ToRdf versions of expand 0124-6. --- tests/toRdf/e124-context.jsonld | 12 ++++++++++++ tests/toRdf/e125-context-1.jsonld | 12 ++++++++++++ tests/toRdf/e125-context-2.jsonld | 3 +++ tests/toRdf/e126-context-1.jsonld | 3 +++ tests/toRdf/e126-context-2.jsonld | 3 +++ tests/toRdf/e126-context-3.jsonld | 12 ++++++++++++ tests/toRdf/e126-in.jsonld | 10 ++++++++++ tests/toRdf/e126-out.nq | 2 ++ 8 files changed, 57 insertions(+) create mode 100644 tests/toRdf/e124-context.jsonld create mode 100644 tests/toRdf/e125-context-1.jsonld create mode 100644 tests/toRdf/e125-context-2.jsonld create mode 100644 tests/toRdf/e126-context-1.jsonld create mode 100644 tests/toRdf/e126-context-2.jsonld create mode 100644 tests/toRdf/e126-context-3.jsonld create mode 100644 tests/toRdf/e126-in.jsonld create mode 100644 tests/toRdf/e126-out.nq diff --git a/tests/toRdf/e124-context.jsonld b/tests/toRdf/e124-context.jsonld new file mode 100644 index 00000000..bd77d9a1 --- /dev/null +++ b/tests/toRdf/e124-context.jsonld @@ -0,0 +1,12 @@ +{ + "@context": { + "@version": 1.1, + "prop": { + "@id": "ex:prop", + "@context": "e124-context.jsonld" + }, + "value": { + "@id": "ex:value" + } + } +} diff --git a/tests/toRdf/e125-context-1.jsonld b/tests/toRdf/e125-context-1.jsonld new file mode 100644 index 00000000..514b9f12 --- /dev/null +++ b/tests/toRdf/e125-context-1.jsonld @@ -0,0 +1,12 @@ +{ + "@context": { + "@version": 1.1, + "prop": { + "@id": "ex:prop", + "@context": "e125-context-2.jsonld" + }, + "value": { + "@id": "ex:value" + } + } +} diff --git a/tests/toRdf/e125-context-2.jsonld b/tests/toRdf/e125-context-2.jsonld new file mode 100644 index 00000000..539fc478 --- /dev/null +++ b/tests/toRdf/e125-context-2.jsonld @@ -0,0 +1,3 @@ +{ + "@context": "e125-context-1.jsonld" +} diff --git a/tests/toRdf/e126-context-1.jsonld b/tests/toRdf/e126-context-1.jsonld new file mode 100644 index 00000000..7c22a4f5 --- /dev/null +++ b/tests/toRdf/e126-context-1.jsonld @@ -0,0 +1,3 @@ +{ + "@context": "e126-context-3.jsonld" +} diff --git a/tests/toRdf/e126-context-2.jsonld b/tests/toRdf/e126-context-2.jsonld new file mode 100644 index 00000000..7c22a4f5 --- /dev/null +++ b/tests/toRdf/e126-context-2.jsonld @@ -0,0 +1,3 @@ +{ + "@context": "e126-context-3.jsonld" +} diff --git a/tests/toRdf/e126-context-3.jsonld b/tests/toRdf/e126-context-3.jsonld new file mode 100644 index 00000000..6b150166 --- /dev/null +++ b/tests/toRdf/e126-context-3.jsonld @@ -0,0 +1,12 @@ +{ + "@context": { + "@version": 1.1, + "prop": { + "@id": "ex:prop", + "@context": "e126-context-3.jsonld" + }, + "value": { + "@id": "ex:value" + } + } +} diff --git a/tests/toRdf/e126-in.jsonld b/tests/toRdf/e126-in.jsonld new file mode 100644 index 00000000..722c2a68 --- /dev/null +++ b/tests/toRdf/e126-in.jsonld @@ -0,0 +1,10 @@ +{ + "@context": [ + "e126-context-1.jsonld", + "e126-context-2.jsonld" + ], + "@id": "ex:id", + "prop": { + "value": "v" + } +} diff --git a/tests/toRdf/e126-out.nq b/tests/toRdf/e126-out.nq new file mode 100644 index 00000000..77fbff8f --- /dev/null +++ b/tests/toRdf/e126-out.nq @@ -0,0 +1,2 @@ + _:b0 . +_:b0 "v" . From 87ad3162cbb5ccfaff8caf0db4ba2f3203036eb8 Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Mon, 16 Mar 2020 16:55:23 -0700 Subject: [PATCH 4/6] Move expand/0124-6 to 0126-8 and toRdf/e124-6 to toRdf/e126-8 to avoid overlapping. --- tests/expand/0126-in.jsonld | 5 +---- tests/expand/{0125-in.jsonld => 0127-in.jsonld} | 0 tests/expand/{0124-out.jsonld => 0127-out.jsonld} | 0 tests/expand/0128-in.jsonld | 10 ++++++++++ tests/expand/{0125-out.jsonld => 0128-out.jsonld} | 0 tests/toRdf/e126-in.jsonld | 5 +---- tests/toRdf/{e125-in.jsonld => e127-in.jsonld} | 0 tests/toRdf/{e124-out.nq => e127-out.nq} | 0 tests/toRdf/e128-in.jsonld | 10 ++++++++++ tests/toRdf/{e125-out.nq => e128-out.nq} | 0 10 files changed, 22 insertions(+), 8 deletions(-) rename tests/expand/{0125-in.jsonld => 0127-in.jsonld} (100%) rename tests/expand/{0124-out.jsonld => 0127-out.jsonld} (100%) create mode 100644 tests/expand/0128-in.jsonld rename tests/expand/{0125-out.jsonld => 0128-out.jsonld} (100%) rename tests/toRdf/{e125-in.jsonld => e127-in.jsonld} (100%) rename tests/toRdf/{e124-out.nq => e127-out.nq} (100%) create mode 100644 tests/toRdf/e128-in.jsonld rename tests/toRdf/{e125-out.nq => e128-out.nq} (100%) diff --git a/tests/expand/0126-in.jsonld b/tests/expand/0126-in.jsonld index b98a4e1f..74567168 100644 --- a/tests/expand/0126-in.jsonld +++ b/tests/expand/0126-in.jsonld @@ -1,8 +1,5 @@ { - "@context": [ - "0126-context-1.jsonld", - "0126-context-2.jsonld" - ], + "@context": "0124-context.jsonld", "@id": "ex:id", "prop": { "value": "v" diff --git a/tests/expand/0125-in.jsonld b/tests/expand/0127-in.jsonld similarity index 100% rename from tests/expand/0125-in.jsonld rename to tests/expand/0127-in.jsonld diff --git a/tests/expand/0124-out.jsonld b/tests/expand/0127-out.jsonld similarity index 100% rename from tests/expand/0124-out.jsonld rename to tests/expand/0127-out.jsonld diff --git a/tests/expand/0128-in.jsonld b/tests/expand/0128-in.jsonld new file mode 100644 index 00000000..b98a4e1f --- /dev/null +++ b/tests/expand/0128-in.jsonld @@ -0,0 +1,10 @@ +{ + "@context": [ + "0126-context-1.jsonld", + "0126-context-2.jsonld" + ], + "@id": "ex:id", + "prop": { + "value": "v" + } +} diff --git a/tests/expand/0125-out.jsonld b/tests/expand/0128-out.jsonld similarity index 100% rename from tests/expand/0125-out.jsonld rename to tests/expand/0128-out.jsonld diff --git a/tests/toRdf/e126-in.jsonld b/tests/toRdf/e126-in.jsonld index 722c2a68..64042787 100644 --- a/tests/toRdf/e126-in.jsonld +++ b/tests/toRdf/e126-in.jsonld @@ -1,8 +1,5 @@ { - "@context": [ - "e126-context-1.jsonld", - "e126-context-2.jsonld" - ], + "@context": "e124-context.jsonld", "@id": "ex:id", "prop": { "value": "v" diff --git a/tests/toRdf/e125-in.jsonld b/tests/toRdf/e127-in.jsonld similarity index 100% rename from tests/toRdf/e125-in.jsonld rename to tests/toRdf/e127-in.jsonld diff --git a/tests/toRdf/e124-out.nq b/tests/toRdf/e127-out.nq similarity index 100% rename from tests/toRdf/e124-out.nq rename to tests/toRdf/e127-out.nq diff --git a/tests/toRdf/e128-in.jsonld b/tests/toRdf/e128-in.jsonld new file mode 100644 index 00000000..722c2a68 --- /dev/null +++ b/tests/toRdf/e128-in.jsonld @@ -0,0 +1,10 @@ +{ + "@context": [ + "e126-context-1.jsonld", + "e126-context-2.jsonld" + ], + "@id": "ex:id", + "prop": { + "value": "v" + } +} diff --git a/tests/toRdf/e125-out.nq b/tests/toRdf/e128-out.nq similarity index 100% rename from tests/toRdf/e125-out.nq rename to tests/toRdf/e128-out.nq From 545376bf3ee55b5aeb1e5059bdb3e4035b9fb5f6 Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Mon, 16 Mar 2020 23:24:57 -0700 Subject: [PATCH 5/6] Update context files for expand/0126-8 and toRdf/e126-8. --- tests/expand/0125-context-2.jsonld | 3 --- tests/expand/0126-context-1.jsonld | 3 --- tests/expand/0126-context-2.jsonld | 3 --- .../{0124-context.jsonld => 0126-context.jsonld} | 2 +- tests/expand/0126-in.jsonld | 2 +- .../{0125-context-1.jsonld => 0127-context-1.jsonld} | 2 +- tests/expand/0127-context-2.jsonld | 3 +++ tests/expand/0128-context-1.jsonld | 3 +++ tests/expand/0128-context-2.jsonld | 3 +++ .../{0126-context-3.jsonld => 0128-context-3.jsonld} | 2 +- tests/expand/0128-in.jsonld | 4 ++-- tests/toRdf/e126-context.jsonld | 12 ++++++++++++ tests/toRdf/e126-in.jsonld | 2 +- tests/toRdf/e127-context-1.jsonld | 12 ++++++++++++ tests/toRdf/e127-context-2.jsonld | 3 +++ tests/toRdf/e128-context-1.jsonld | 3 +++ tests/toRdf/e128-context-2.jsonld | 3 +++ tests/toRdf/e128-context-3.jsonld | 12 ++++++++++++ tests/toRdf/e128-in.jsonld | 4 ++-- 19 files changed, 63 insertions(+), 18 deletions(-) delete mode 100644 tests/expand/0125-context-2.jsonld delete mode 100644 tests/expand/0126-context-1.jsonld delete mode 100644 tests/expand/0126-context-2.jsonld rename tests/expand/{0124-context.jsonld => 0126-context.jsonld} (77%) rename tests/expand/{0125-context-1.jsonld => 0127-context-1.jsonld} (76%) create mode 100644 tests/expand/0127-context-2.jsonld create mode 100644 tests/expand/0128-context-1.jsonld create mode 100644 tests/expand/0128-context-2.jsonld rename tests/expand/{0126-context-3.jsonld => 0128-context-3.jsonld} (76%) create mode 100644 tests/toRdf/e126-context.jsonld create mode 100644 tests/toRdf/e127-context-1.jsonld create mode 100644 tests/toRdf/e127-context-2.jsonld create mode 100644 tests/toRdf/e128-context-1.jsonld create mode 100644 tests/toRdf/e128-context-2.jsonld create mode 100644 tests/toRdf/e128-context-3.jsonld diff --git a/tests/expand/0125-context-2.jsonld b/tests/expand/0125-context-2.jsonld deleted file mode 100644 index 8d63a813..00000000 --- a/tests/expand/0125-context-2.jsonld +++ /dev/null @@ -1,3 +0,0 @@ -{ - "@context": "0125-context-1.jsonld" -} diff --git a/tests/expand/0126-context-1.jsonld b/tests/expand/0126-context-1.jsonld deleted file mode 100644 index 4c695ba2..00000000 --- a/tests/expand/0126-context-1.jsonld +++ /dev/null @@ -1,3 +0,0 @@ -{ - "@context": "0126-context-3.jsonld" -} diff --git a/tests/expand/0126-context-2.jsonld b/tests/expand/0126-context-2.jsonld deleted file mode 100644 index 4c695ba2..00000000 --- a/tests/expand/0126-context-2.jsonld +++ /dev/null @@ -1,3 +0,0 @@ -{ - "@context": "0126-context-3.jsonld" -} diff --git a/tests/expand/0124-context.jsonld b/tests/expand/0126-context.jsonld similarity index 77% rename from tests/expand/0124-context.jsonld rename to tests/expand/0126-context.jsonld index 165ec43b..928397cb 100644 --- a/tests/expand/0124-context.jsonld +++ b/tests/expand/0126-context.jsonld @@ -3,7 +3,7 @@ "@version": 1.1, "prop": { "@id": "ex:prop", - "@context": "0124-context.jsonld" + "@context": "0126-context.jsonld" }, "value": { "@id": "ex:value" diff --git a/tests/expand/0126-in.jsonld b/tests/expand/0126-in.jsonld index 74567168..b36e1085 100644 --- a/tests/expand/0126-in.jsonld +++ b/tests/expand/0126-in.jsonld @@ -1,5 +1,5 @@ { - "@context": "0124-context.jsonld", + "@context": "0126-context.jsonld", "@id": "ex:id", "prop": { "value": "v" diff --git a/tests/expand/0125-context-1.jsonld b/tests/expand/0127-context-1.jsonld similarity index 76% rename from tests/expand/0125-context-1.jsonld rename to tests/expand/0127-context-1.jsonld index 10f09041..80615617 100644 --- a/tests/expand/0125-context-1.jsonld +++ b/tests/expand/0127-context-1.jsonld @@ -3,7 +3,7 @@ "@version": 1.1, "prop": { "@id": "ex:prop", - "@context": "0125-context-2.jsonld" + "@context": "0127-context-2.jsonld" }, "value": { "@id": "ex:value" diff --git a/tests/expand/0127-context-2.jsonld b/tests/expand/0127-context-2.jsonld new file mode 100644 index 00000000..2d23df43 --- /dev/null +++ b/tests/expand/0127-context-2.jsonld @@ -0,0 +1,3 @@ +{ + "@context": "0127-context-1.jsonld" +} diff --git a/tests/expand/0128-context-1.jsonld b/tests/expand/0128-context-1.jsonld new file mode 100644 index 00000000..9d520ad8 --- /dev/null +++ b/tests/expand/0128-context-1.jsonld @@ -0,0 +1,3 @@ +{ + "@context": "0128-context-3.jsonld" +} diff --git a/tests/expand/0128-context-2.jsonld b/tests/expand/0128-context-2.jsonld new file mode 100644 index 00000000..9d520ad8 --- /dev/null +++ b/tests/expand/0128-context-2.jsonld @@ -0,0 +1,3 @@ +{ + "@context": "0128-context-3.jsonld" +} diff --git a/tests/expand/0126-context-3.jsonld b/tests/expand/0128-context-3.jsonld similarity index 76% rename from tests/expand/0126-context-3.jsonld rename to tests/expand/0128-context-3.jsonld index 4e152051..31bcb7b8 100644 --- a/tests/expand/0126-context-3.jsonld +++ b/tests/expand/0128-context-3.jsonld @@ -3,7 +3,7 @@ "@version": 1.1, "prop": { "@id": "ex:prop", - "@context": "0126-context-3.jsonld" + "@context": "0128-context-3.jsonld" }, "value": { "@id": "ex:value" diff --git a/tests/expand/0128-in.jsonld b/tests/expand/0128-in.jsonld index b98a4e1f..8ef7fafa 100644 --- a/tests/expand/0128-in.jsonld +++ b/tests/expand/0128-in.jsonld @@ -1,7 +1,7 @@ { "@context": [ - "0126-context-1.jsonld", - "0126-context-2.jsonld" + "0128-context-1.jsonld", + "0128-context-2.jsonld" ], "@id": "ex:id", "prop": { diff --git a/tests/toRdf/e126-context.jsonld b/tests/toRdf/e126-context.jsonld new file mode 100644 index 00000000..548ae93f --- /dev/null +++ b/tests/toRdf/e126-context.jsonld @@ -0,0 +1,12 @@ +{ + "@context": { + "@version": 1.1, + "prop": { + "@id": "ex:prop", + "@context": "e126-context.jsonld" + }, + "value": { + "@id": "ex:value" + } + } +} diff --git a/tests/toRdf/e126-in.jsonld b/tests/toRdf/e126-in.jsonld index 64042787..32f41007 100644 --- a/tests/toRdf/e126-in.jsonld +++ b/tests/toRdf/e126-in.jsonld @@ -1,5 +1,5 @@ { - "@context": "e124-context.jsonld", + "@context": "e126-context.jsonld", "@id": "ex:id", "prop": { "value": "v" diff --git a/tests/toRdf/e127-context-1.jsonld b/tests/toRdf/e127-context-1.jsonld new file mode 100644 index 00000000..bd82f33d --- /dev/null +++ b/tests/toRdf/e127-context-1.jsonld @@ -0,0 +1,12 @@ +{ + "@context": { + "@version": 1.1, + "prop": { + "@id": "ex:prop", + "@context": "e127-context-2.jsonld" + }, + "value": { + "@id": "ex:value" + } + } +} diff --git a/tests/toRdf/e127-context-2.jsonld b/tests/toRdf/e127-context-2.jsonld new file mode 100644 index 00000000..d7c1f2c9 --- /dev/null +++ b/tests/toRdf/e127-context-2.jsonld @@ -0,0 +1,3 @@ +{ + "@context": "e127-context-1.jsonld" +} diff --git a/tests/toRdf/e128-context-1.jsonld b/tests/toRdf/e128-context-1.jsonld new file mode 100644 index 00000000..6586e453 --- /dev/null +++ b/tests/toRdf/e128-context-1.jsonld @@ -0,0 +1,3 @@ +{ + "@context": "e128-context-3.jsonld" +} diff --git a/tests/toRdf/e128-context-2.jsonld b/tests/toRdf/e128-context-2.jsonld new file mode 100644 index 00000000..6586e453 --- /dev/null +++ b/tests/toRdf/e128-context-2.jsonld @@ -0,0 +1,3 @@ +{ + "@context": "e128-context-3.jsonld" +} diff --git a/tests/toRdf/e128-context-3.jsonld b/tests/toRdf/e128-context-3.jsonld new file mode 100644 index 00000000..5f71478b --- /dev/null +++ b/tests/toRdf/e128-context-3.jsonld @@ -0,0 +1,12 @@ +{ + "@context": { + "@version": 1.1, + "prop": { + "@id": "ex:prop", + "@context": "e128-context-3.jsonld" + }, + "value": { + "@id": "ex:value" + } + } +} diff --git a/tests/toRdf/e128-in.jsonld b/tests/toRdf/e128-in.jsonld index 722c2a68..4da4e6c8 100644 --- a/tests/toRdf/e128-in.jsonld +++ b/tests/toRdf/e128-in.jsonld @@ -1,7 +1,7 @@ { "@context": [ - "e126-context-1.jsonld", - "e126-context-2.jsonld" + "e128-context-1.jsonld", + "e128-context-2.jsonld" ], "@id": "ex:id", "prop": { From 239c3eb8b999984a098a037705307c59fd19f635 Mon Sep 17 00:00:00 2001 From: Gregg Kellogg Date: Mon, 16 Mar 2020 23:33:59 -0700 Subject: [PATCH 6/6] Update use of _validate scoped contexts_ to skip only if `false` and the context is in the _remote contexts_ array, which allows for validating scoped contexts when the term is defined up to the point that it has already been processed. --- index.html | 18 +++++--- tests/expand-manifest.html | 84 ++++++++++++++++++++++++++++++++++++ tests/expand-manifest.jsonld | 24 +++++++++++ tests/expand/0124-out.jsonld | 9 ++++ tests/expand/0125-in.jsonld | 15 +++++++ tests/expand/0125-out.jsonld | 9 ++++ tests/expand/0127-in.jsonld | 18 +++----- tests/expand/0127-out.jsonld | 9 +++- tests/expand/0128-out.jsonld | 9 +++- tests/toRdf-manifest.html | 84 ++++++++++++++++++++++++++++++++++++ tests/toRdf-manifest.jsonld | 24 +++++++++++ tests/toRdf/e124-out.nq | 1 + tests/toRdf/e125-in.jsonld | 15 +++++++ tests/toRdf/e125-out.nq | 1 + tests/toRdf/e127-in.jsonld | 18 +++----- tests/toRdf/e127-out.nq | 3 +- tests/toRdf/e128-out.nq | 3 +- 17 files changed, 306 insertions(+), 38 deletions(-) create mode 100644 tests/expand/0124-out.jsonld create mode 100644 tests/expand/0125-in.jsonld create mode 100644 tests/expand/0125-out.jsonld create mode 100644 tests/toRdf/e124-out.nq create mode 100644 tests/toRdf/e125-in.jsonld create mode 100644 tests/toRdf/e125-out.nq diff --git a/index.html b/index.html index eef01120..653df659 100644 --- a/index.html +++ b/index.html @@ -1261,6 +1261,10 @@

    Algorithm

    context overflow error has been detected and processing is aborted; otherwise, add context to remote contexts. +
  • If validate scoped context is false, + and remote contexts already includes context + do not process context further and continue to any next + context in local context.
  • If context was previously dereferenced, then the processor MUST NOT do a further dereference, and context is set to the @@ -1292,16 +1296,14 @@

    Algorithm

  • Set loaded context to the value of that entry.
  • -
  • If validate scoped context is false, - do not process loaded context and continue to any next - context in local context.
  • Set result to the result of recursively calling this algorithm, passing result for active context, loaded context for local context, the {{RemoteDocument/documentUrl}} of context document for base URL, - and a copy of remote contexts. + a copy of remote contexts, + and validate scoped context.
    If context was previously dereferenced, processors MUST make provisions for retaining the base URL of that context for this step to enable the resolution of any @@ -1477,6 +1479,7 @@

    Algorithm

    base URL, the value of the @protected entry from context, if any, for protected, + a copy of remote contexts, and validate scoped context.
  • @@ -1525,7 +1528,7 @@

    Overview

    Algorithm

    -

    The algorithm has four required and four optional inputs. +

    The algorithm has four required and five optional inputs. The required inputs are an active context, a local context, @@ -1536,6 +1539,8 @@

    Algorithm

    protected which defaults to false, and override protected, defaulting to false, which is used to allow changes to protected terms, + an array remote contexts, + defaulting to a new empty array, which is used to detect cyclical context inclusions, and validate scoped context defaulting to true, which is used to limit recursion when validating possibly recusive scoped contexts..

    @@ -1814,6 +1819,7 @@

    Algorithm

    using the active context, context as local context, base URL, true for override protected, + a copy of remote contexts, and false for validate scoped context. If any error is detected, an invalid scoped context error @@ -7002,7 +7008,7 @@

    Changes since Candidate Release of 05 March 2020

    of to exclude `@type`, leaving it to the next step. This could cause type values from a node to be left out of the merge. -
  • Added step 5.2.5 +
  • Added step 5.2.3 to the Context Processing algorithm, which is added validate scoped context as a new optional argument, and passed to the diff --git a/tests/expand-manifest.html b/tests/expand-manifest.html index d269472d..90d634f9 100644 --- a/tests/expand-manifest.html +++ b/tests/expand-manifest.html @@ -3086,6 +3086,90 @@

    +
    +Test t0126 A scoped context may include itself recursively (direct) +
    +
    +
    +
    id
    +
    #t0126
    +
    Type
    +
    jld:PositiveEvaluationTest, jld:ExpandTest
    +
    Purpose
    +
    Verifies that no exception is raised on expansion when processing a scoped context referencing itself directly
    +
    input
    +
    +expand/0126-in.jsonld +
    +
    expect
    +
    +expand/0126-out.jsonld +
    +
    Options
    +
    +
    +
    specVersion
    +
    json-ld-1.1
    +
    +
    +
    +
    +
    +Test t0127 A scoped context may include itself recursively (indirect) +
    +
    +
    +
    id
    +
    #t0127
    +
    Type
    +
    jld:PositiveEvaluationTest, jld:ExpandTest
    +
    Purpose
    +
    Verifies that no exception is raised on expansion when processing a scoped context referencing itself indirectly
    +
    input
    +
    +expand/0127-in.jsonld +
    +
    expect
    +
    +expand/0127-out.jsonld +
    +
    Options
    +
    +
    +
    specVersion
    +
    json-ld-1.1
    +
    +
    +
    +
    +
    +Test t0128 Two scoped context may include a shared context +
    +
    +
    +
    id
    +
    #t0128
    +
    Type
    +
    jld:PositiveEvaluationTest, jld:ExpandTest
    +
    Purpose
    +
    Verifies that no exception is raised on expansion when processing two scoped contexts referencing a shared context
    +
    input
    +
    +expand/0128-in.jsonld +
    +
    expect
    +
    +expand/0128-out.jsonld +
    +
    Options
    +
    +
    +
    specVersion
    +
    json-ld-1.1
    +
    +
    +
    +
    Test tc001 adding new term
    diff --git a/tests/expand-manifest.jsonld b/tests/expand-manifest.jsonld index e5ad6fec..577d650b 100644 --- a/tests/expand-manifest.jsonld +++ b/tests/expand-manifest.jsonld @@ -940,6 +940,30 @@ "input": "expand/0125-in.jsonld", "expect": "expand/0125-out.jsonld", "option": {"specVersion": "json-ld-1.1"} + }, { + "@id": "#t0126", + "@type": [ "jld:PositiveEvaluationTest", "jld:ExpandTest" ], + "name": "A scoped context may include itself recursively (direct)", + "purpose": "Verifies that no exception is raised on expansion when processing a scoped context referencing itself directly", + "input": "expand/0126-in.jsonld", + "expect": "expand/0126-out.jsonld", + "option": {"specVersion": "json-ld-1.1"} + }, { + "@id": "#t0127", + "@type": [ "jld:PositiveEvaluationTest", "jld:ExpandTest" ], + "name": "A scoped context may include itself recursively (indirect)", + "purpose": "Verifies that no exception is raised on expansion when processing a scoped context referencing itself indirectly", + "input": "expand/0127-in.jsonld", + "expect": "expand/0127-out.jsonld", + "option": {"specVersion": "json-ld-1.1"} + }, { + "@id": "#t0128", + "@type": [ "jld:PositiveEvaluationTest", "jld:ExpandTest" ], + "name": "Two scoped context may include a shared context", + "purpose": "Verifies that no exception is raised on expansion when processing two scoped contexts referencing a shared context", + "input": "expand/0128-in.jsonld", + "expect": "expand/0128-out.jsonld", + "option": {"specVersion": "json-ld-1.1"} }, { "@id": "#tc001", "@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"], diff --git a/tests/expand/0124-out.jsonld b/tests/expand/0124-out.jsonld new file mode 100644 index 00000000..84f89a4c --- /dev/null +++ b/tests/expand/0124-out.jsonld @@ -0,0 +1,9 @@ +[ + { + "http://example.org/ns/foo": [ + { + "@value": "bar" + } + ] + } +] diff --git a/tests/expand/0125-in.jsonld b/tests/expand/0125-in.jsonld new file mode 100644 index 00000000..92b3ef61 --- /dev/null +++ b/tests/expand/0125-in.jsonld @@ -0,0 +1,15 @@ +{ + "@context": [ + { + "@version": 1.1, + "ex": { + "@id": "http://example.org/", + "@prefix": true + } + }, + { + "@vocab": "ex" + } + ], + "foo": "bar" +} diff --git a/tests/expand/0125-out.jsonld b/tests/expand/0125-out.jsonld new file mode 100644 index 00000000..23e2700c --- /dev/null +++ b/tests/expand/0125-out.jsonld @@ -0,0 +1,9 @@ +[ + { + "http://example.org/foo": [ + { + "@value": "bar" + } + ] + } +] diff --git a/tests/expand/0127-in.jsonld b/tests/expand/0127-in.jsonld index 92b3ef61..3b5668fd 100644 --- a/tests/expand/0127-in.jsonld +++ b/tests/expand/0127-in.jsonld @@ -1,15 +1,7 @@ { - "@context": [ - { - "@version": 1.1, - "ex": { - "@id": "http://example.org/", - "@prefix": true - } - }, - { - "@vocab": "ex" - } - ], - "foo": "bar" + "@context": "0127-context-1.jsonld", + "@id": "ex:id", + "prop": { + "value": "v" + } } diff --git a/tests/expand/0127-out.jsonld b/tests/expand/0127-out.jsonld index 84f89a4c..bdf762a6 100644 --- a/tests/expand/0127-out.jsonld +++ b/tests/expand/0127-out.jsonld @@ -1,8 +1,13 @@ [ { - "http://example.org/ns/foo": [ + "@id": "ex:id", + "ex:prop": [ { - "@value": "bar" + "ex:value": [ + { + "@value": "v" + } + ] } ] } diff --git a/tests/expand/0128-out.jsonld b/tests/expand/0128-out.jsonld index 23e2700c..bdf762a6 100644 --- a/tests/expand/0128-out.jsonld +++ b/tests/expand/0128-out.jsonld @@ -1,8 +1,13 @@ [ { - "http://example.org/foo": [ + "@id": "ex:id", + "ex:prop": [ { - "@value": "bar" + "ex:value": [ + { + "@value": "v" + } + ] } ] } diff --git a/tests/toRdf-manifest.html b/tests/toRdf-manifest.html index 825c7378..08e54e57 100644 --- a/tests/toRdf-manifest.html +++ b/tests/toRdf-manifest.html @@ -5561,6 +5561,90 @@

    +
    +Test te126 A scoped context may include itself recursively (direct) +
    +
    +
    +
    id
    +
    #te126
    +
    Type
    +
    jld:PositiveEvaluationTest, jld:ToRDFTest
    +
    Purpose
    +
    Verifies that no exception is raised on expansion when processing a scoped context referencing itself directly
    +
    input
    +
    +toRdf/e126-in.jsonld +
    +
    expect
    +
    +toRdf/e126-out.nq +
    +
    Options
    +
    +
    +
    specVersion
    +
    json-ld-1.1
    +
    +
    +
    +
    +
    +Test te127 A scoped context may include itself recursively (indirect) +
    +
    +
    +
    id
    +
    #te127
    +
    Type
    +
    jld:PositiveEvaluationTest, jld:ToRDFTest
    +
    Purpose
    +
    Verifies that no exception is raised on expansion when processing a scoped context referencing itself indirectly
    +
    input
    +
    +toRdf/e127-in.jsonld +
    +
    expect
    +
    +toRdf/e127-out.nq +
    +
    Options
    +
    +
    +
    specVersion
    +
    json-ld-1.1
    +
    +
    +
    +
    +
    +Test te128 Two scoped context may include a shared context +
    +
    +
    +
    id
    +
    #te128
    +
    Type
    +
    jld:PositiveEvaluationTest, jld:ToRDFTest
    +
    Purpose
    +
    Verifies that no exception is raised on expansion when processing two scoped contexts referencing a shared context
    +
    input
    +
    +toRdf/e128-in.jsonld +
    +
    expect
    +
    +toRdf/e128-out.nq +
    +
    Options
    +
    +
    +
    specVersion
    +
    json-ld-1.1
    +
    +
    +
    +
    Test tec01 Invalid keyword in term definition
    diff --git a/tests/toRdf-manifest.jsonld b/tests/toRdf-manifest.jsonld index 30c64a33..6f623012 100644 --- a/tests/toRdf-manifest.jsonld +++ b/tests/toRdf-manifest.jsonld @@ -1708,6 +1708,30 @@ "input": "toRdf/e125-in.jsonld", "expect": "toRdf/e125-out.nq", "option": {"specVersion": "json-ld-1.1"} + }, { + "@id": "#te126", + "@type": [ "jld:PositiveEvaluationTest", "jld:ToRDFTest" ], + "name": "A scoped context may include itself recursively (direct)", + "purpose": "Verifies that no exception is raised on expansion when processing a scoped context referencing itself directly", + "input": "toRdf/e126-in.jsonld", + "expect": "toRdf/e126-out.nq", + "option": {"specVersion": "json-ld-1.1"} + }, { + "@id": "#te127", + "@type": [ "jld:PositiveEvaluationTest", "jld:ToRDFTest" ], + "name": "A scoped context may include itself recursively (indirect)", + "purpose": "Verifies that no exception is raised on expansion when processing a scoped context referencing itself indirectly", + "input": "toRdf/e127-in.jsonld", + "expect": "toRdf/e127-out.nq", + "option": {"specVersion": "json-ld-1.1"} + }, { + "@id": "#te128", + "@type": [ "jld:PositiveEvaluationTest", "jld:ToRDFTest" ], + "name": "Two scoped context may include a shared context", + "purpose": "Verifies that no exception is raised on expansion when processing two scoped contexts referencing a shared context", + "input": "toRdf/e128-in.jsonld", + "expect": "toRdf/e128-out.nq", + "option": {"specVersion": "json-ld-1.1"} }, { "@id": "#tec01", "@type": [ "jld:NegativeEvaluationTest", "jld:ToRDFTest" ], diff --git a/tests/toRdf/e124-out.nq b/tests/toRdf/e124-out.nq new file mode 100644 index 00000000..290c77cc --- /dev/null +++ b/tests/toRdf/e124-out.nq @@ -0,0 +1 @@ +_:b0 "bar" . diff --git a/tests/toRdf/e125-in.jsonld b/tests/toRdf/e125-in.jsonld new file mode 100644 index 00000000..92b3ef61 --- /dev/null +++ b/tests/toRdf/e125-in.jsonld @@ -0,0 +1,15 @@ +{ + "@context": [ + { + "@version": 1.1, + "ex": { + "@id": "http://example.org/", + "@prefix": true + } + }, + { + "@vocab": "ex" + } + ], + "foo": "bar" +} diff --git a/tests/toRdf/e125-out.nq b/tests/toRdf/e125-out.nq new file mode 100644 index 00000000..c6e92021 --- /dev/null +++ b/tests/toRdf/e125-out.nq @@ -0,0 +1 @@ +_:b0 "bar" . diff --git a/tests/toRdf/e127-in.jsonld b/tests/toRdf/e127-in.jsonld index 92b3ef61..dcde2823 100644 --- a/tests/toRdf/e127-in.jsonld +++ b/tests/toRdf/e127-in.jsonld @@ -1,15 +1,7 @@ { - "@context": [ - { - "@version": 1.1, - "ex": { - "@id": "http://example.org/", - "@prefix": true - } - }, - { - "@vocab": "ex" - } - ], - "foo": "bar" + "@context": "e127-context-1.jsonld", + "@id": "ex:id", + "prop": { + "value": "v" + } } diff --git a/tests/toRdf/e127-out.nq b/tests/toRdf/e127-out.nq index 290c77cc..77fbff8f 100644 --- a/tests/toRdf/e127-out.nq +++ b/tests/toRdf/e127-out.nq @@ -1 +1,2 @@ -_:b0 "bar" . + _:b0 . +_:b0 "v" . diff --git a/tests/toRdf/e128-out.nq b/tests/toRdf/e128-out.nq index c6e92021..77fbff8f 100644 --- a/tests/toRdf/e128-out.nq +++ b/tests/toRdf/e128-out.nq @@ -1 +1,2 @@ -_:b0 "bar" . + _:b0 . +_:b0 "v" .