diff --git a/Gemfile b/Gemfile index 37e747e2..8eba7cb6 100644 --- a/Gemfile +++ b/Gemfile @@ -1,8 +1,10 @@ source "https://rubygems.org" gem 'json-ld', github: 'ruby-rdf/json-ld', branch: 'develop' +gem 'json-ld-preloaded' gem 'nokogiri' gem 'nokogumbo' gem 'linkeddata' gem 'colorize' gem 'rake' +gem 'byebug' diff --git a/Gemfile.lock b/Gemfile.lock index 19b35316..37866348 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT - remote: git://github.com/ruby-rdf/json-ld.git - revision: 74a05a9f623c5a9e02cbe42f053f9d09181fee97 + remote: https://github.com/ruby-rdf/json-ld.git + revision: 74095b73cdb722b681f34d0f165599c9cb48d844 branch: develop specs: json-ld (3.0.2) @@ -18,6 +18,7 @@ GEM bcp47 (0.3.3) i18n builder (3.2.3) + byebug (11.0.1) colorize (0.8.1) concurrent-ruby (1.1.5) connection_pool (2.2.2) @@ -26,7 +27,7 @@ GEM sxp (~> 1.0) equivalent-xml (0.6.0) nokogiri (>= 1.4.3) - haml (5.0.4) + haml (5.1.1) temple (>= 0.8.0) tilt hamster (3.0.0) @@ -73,13 +74,13 @@ GEM sparql-client (~> 3.0) mini_portile2 (2.4.0) multi_json (1.13.1) - net-http-persistent (3.0.0) + net-http-persistent (3.0.1) connection_pool (~> 2.2) nokogiri (1.10.3) mini_portile2 (~> 2.4.0) nokogumbo (1.5.0) nokogiri - public_suffix (3.0.3) + public_suffix (3.1.1) rack (2.0.7) rake (12.3.2) rdf (3.0.12) @@ -113,17 +114,17 @@ GEM rdf (>= 2.2, < 4.0) rdf-rdfa (>= 2.2, < 4.0) rdf-xsd (>= 2.2, < 4.0) - rdf-reasoner (0.5.1) + rdf-reasoner (0.5.2) rdf (~> 3.0) rdf-vocab (~> 3.0) rdf-xsd (~> 3.0) - rdf-tabular (2.2.1) + rdf-tabular (2.2.2) addressable (~> 2.3) bcp47 (~> 0.3, >= 0.3.3) json-ld (>= 2.1, < 4.0) - rdf (>= 2.2, < 4.0) - rdf-vocab (>= 2.2, < 4.0) - rdf-xsd (>= 2.2, < 4.0) + rdf (~> 3.0) + rdf-vocab (~> 3.0) + rdf-xsd (~> 3.0) rdf-trig (3.0.1) ebnf (~> 1.1) rdf (~> 3.0) @@ -133,7 +134,7 @@ GEM rdf-turtle (3.0.6) ebnf (~> 1.1) rdf (~> 3.0) - rdf-vocab (3.0.5) + rdf-vocab (3.0.7) rdf (~> 3.0, >= 3.0.11) rdf-xsd (3.0.1) rdf (~> 3.0) @@ -165,12 +166,14 @@ PLATFORMS ruby DEPENDENCIES + byebug colorize json-ld! + json-ld-preloaded linkeddata nokogiri nokogumbo rake BUNDLED WITH - 1.17.3 + 2.0.2 diff --git a/common/extract-examples.rb b/common/extract-examples.rb index a1890632..44fc8eb3 100755 --- a/common/extract-examples.rb +++ b/common/extract-examples.rb @@ -10,6 +10,7 @@ # - @data-options indicates the comma-separated option/value pairs to pass to the processor require 'getoptlong' require 'json' +require 'json/ld/preloaded' require 'nokogiri' require 'linkeddata' require 'fileutils' diff --git a/index.html b/index.html index 99878fc9..1e73b713 100644 --- a/index.html +++ b/index.html @@ -591,9 +591,19 @@

Syntax Tokens and Keywords

Used as the @type value of a JSON literal. This keyword is described in . -
:
-
The separator for JSON keys and values that use - compact IRIs.
+
:
+ The separator for JSON keys and values that use compact IRIs.
+
`@propagate`
+ Used in a context definition to change the sccope of that context. + By default, it is `true`, + meaning that contexts propagate across node objects + (other than for type-scoped contexts, which default to `false`). + Setting this to `false` causes term definitions created within that context + to be removed when entering a new node object.
+
`@import`
+ Used in a context definition to load an external context + within which the containing context definition is merged. + This can be useful to add JSON-LD 1.1 features to JSON-LD 1.0 contexts.

All keys, keywords, and values in JSON-LD are case-sensitive.

@@ -2969,7 +2979,6 @@

Using the Document Base for the Default Vocabulary

Aliasing Keywords

-

Each of the JSON-LD keywords, except for @context, may be aliased to application-specific keywords. This feature allows legacy JSON content to be utilized @@ -3409,7 +3418,9 @@

Using the Document Base for the Default Vocabulary

different things depending on the context. A context scoped on @type is only in effect for the node object on which the type is used; the previous in-scope contexts are placed back into - effect when traversing into another node object.

+ effect when traversing into another node object. + As described further in , + this may be controlled using the `@propagate` keyword.

Any property-scoped or local contexts that were introduced in the node object would still be in effect when traversing into another node object.

@@ -3521,6 +3532,248 @@

Using the Document Base for the Default Vocabulary

processing mode set to json-ld-1.1.

+

Context Propagation

+

Once introduced, contexts remain in effect until a subsequent + context removes it by setting `@context` to `null`, + or by redefining terms, + with the exception of type-scoped contexts, + which limits the affect of that context until the next node object is entered. + This behavior can be changed using the `@propagate` keyword.

+ +

The following example illustrates how terms defined in a context with `@propagate` set to `false` + are effectively removed when descending into new node object.

+ + + +

Contexts included within an array must all have the same value for `@propagate` + due to the way that rollback is defined in [[[JSON-LD11-API]]].

+
+ +

Imported Contexts

+

JSON-LD 1.0 included mechanisms for modifying the context that + is in effect. This included the capability to load and process a remote + context and then apply further changes to it via new contexts. +

+ +

However, with the introduction of JSON-LD 1.1, it is also desirable to + be able to load a remote context, in particular an existing JSON-LD + 1.0 context, and apply JSON-LD 1.1 features to it prior to + processing.

+ +

By using the `@import` keyword in a context, another remote + context, referred to as an imported context, can be loaded and + modified prior to processing. The modifications are expressed in the + context that includes the `@import` keyword, referred to as the + wrapping context. Once an imported context is loaded, the + contents of the wrapping context are merged into it prior to + processing. The merge operation will cause each key-value pair in the + wrapping context to be added to the loaded imported context, + with the wrapping context key-value pairs taking precedence.

+ +

By enabling existing contexts to be reused and edited inline prior + to processing, context-wide keywords can be applied to adjust all term + definitions in the imported context. Similarly, term definitions can + be replaced prior to processing, enabling adjustments that, for instance, ensure term + definitions match previously protected terms or that they include + additional type coercion information.

+ +

The following examples illustrate how `@import` can be used to express + a type-scoped context that loads an imported context and + sets `@propagate` to `true` and how to make similar modifications.

+ +

Suppose there was a context that could be referenced remotely + via the URL https://json-ld.org/contexts/remote-context.jsonld:

+ +
+  
+  
+ +

A wrapping context could be used to source it and modify it:

+ +
+  
+  
+ +

The effect would be the same as if the entire imported context + had been copied into the type-scoped context:

+ +
+  
+  
+ +

Similarly, the wrapping context may replace term definitions or + set other context-wide keywords that may effect how the imported + context term definitions will be processed:

+ +
+  
+  
+ +

Again, the effect would be the same as if the entire imported context + had been copied into the context:

+ +
+  
+  
+ +

The result of loading imported contexts must be + an object, not an array.

+
+

Protected Term Definitions

JSON-LD is used in many specifications as the specified data format. However, there is also a desire to allow some JSON-LD contents to be processed as plain JSON, @@ -11711,13 +11964,15 @@

Context Definitions

An expanded term definition MUST be a map composed of zero or more keys from @id, + @import, @reverse, @type, @language, + @container, @context, @prefix, or - @container. An - expanded term definition SHOULD NOT contain any other keys.

+ @propagate. + An expanded term definition SHOULD NOT contain any other keys.

If the term being defined is not a compact IRI or absolute IRI and the active context does not have an @@ -11783,6 +12038,12 @@

Context Definitions

If the expanded term definition contains the @prefix keyword, its value MUST be true or false.

+

If the expanded term definition contains the @propagate + keyword, its value MUST be true or false.

+ +

If the expanded term definition contains the @import + keyword, its value MUST be an absolute IRI or relative IRI.

+

Terms MUST NOT be used in a circular manner. That is, the definition of a term cannot depend on the definition of another term if that other term also depends on the first term.

@@ -11790,7 +12051,7 @@

Context Definitions

See for further discussion on contexts.

-
+

Keywords

JSON-LD keywords are described in , this section describes where each keyword may appear within different JSON-LD structures.

@@ -11807,17 +12068,17 @@

Keywords

@set, @language, @index, - @id, - @graph, - @type, or be + @id, + @graph, + @type, or be null, - or an array containing exactly any one of those keywords, or a - combination of @set and any of @index, - @id, @graph, @type, - @language in any order. - The value may also be an array - containing @graph along with either @id or - @index and also optionally including @set. + or an array containing exactly any one of those keywords, or a + combination of @set and any of @index, + @id, @graph, @type, + @language in any order. + The value may also be an array + containing @graph along with either @id or + @index and also optionally including @set.
@context
The @context keyword MUST NOT be aliased, and MAY be used as a key in the following objects: @@ -11837,6 +12098,12 @@

Keywords

a context definition, or an array composed of any of these.
+
`@graph`
+ The `@graph` keyword MAY be aliased and MAY be used as a key in a node object or a graph object. + The unaliased `@graph` MAY be used as the value of the @container key within an expanded term definition. + The value of the `@graph` key MUST be a value object, node object, or an array of either value objects or node objects. + See . +
@id
The @id keyword MAY be aliased and MAY be used as a key in a node object or a graph object. The unaliased @id MAY be used as a key in an expanded term definition, @@ -11879,7 +12146,7 @@

Keywords

See for further discussion on sets and lists.

-
@nest
+
@nest
The @nest keyword MAY be aliased and MAY be used as a key in a node object. The unaliased @nest MAY be used as the value of a simple term definition, or as a key in an expanded term definition. @@ -11888,7 +12155,7 @@

Keywords

Its value MUST be a string. See for a further discussion.
-
@none
+
@none
The @none keyword MAY be aliased and MAY be used as a key in an index map, id map, language map, type map. See , @@ -11898,13 +12165,18 @@

Keywords

, or for a further discussion.
-
@prefix
+
@prefix
The @prefix keyword MUST NOT be aliased, and MAY be used as a key in an expanded term definition. Its value MUST be true or false. See and for a further discussion.
+
`@propagate`
+ The `@propagate` keyword MUST NOT be aliased, and MAY be used in a context definition. + Its value MUST be true or false. + See for a further discussion. +
@reverse
The @reverse keyword MAY be aliased and MAY be used as a key in a node object. The unaliased @reverse MAY be used as a key in an expanded term definition. @@ -11930,6 +12202,11 @@

Keywords

See for further discussion on sets and lists.

+
`@import`
+ The `@import` keyword MUST NOT be aliased, and MAY be used in a context definition. + Its value MUST be an absolute IRI or relative IRI. + See for a further discussion. +
@type
The @type keyword MAY be aliased and MAY be used as a key in a node object or a value object. The unaliased @type MAY be used as a key in an expanded term definition, @@ -11945,7 +12222,7 @@

Keywords

Its value key MUST be either a string, a number, true, false or null. This keyword is described further in .
-
@version
+
@version
The @version keyword MUST NOT be aliased and MAY be used as a key in a context definition. Its value MUST be a number with the value 1.1. This keyword is described further in . @@ -12876,6 +13153,12 @@

Changes since JSON-LD Community Group Final Report

to limit the ability of other contexts to override them.
  • A context defined in an expanded term definition may also be used for values of @type, which defines a context to use for node objects including the associated type.
  • +
  • By default, all contexts are propagated when traversing node objects, other than + type-scoped contexts. This can be controlled using the @propagate + entry in a local context.
  • +
  • A context may contain an @import entry used to reference a remote context + within a context, allowing JSON-LD 1.1 features to be added to contexts originally + authored for JSON-LD 1.0.