diff --git a/spec/latest/common/terms.html b/spec/latest/common/terms.html index e9d64b8e7..3c64f5133 100644 --- a/spec/latest/common/terms.html +++ b/spec/latest/common/terms.html @@ -212,6 +212,14 @@

General Terminology

A prefix is a term that expands to a vocabulary base IRI. It is typically used along with a suffix to form a compact IRI to create an IRI within a vocabulary. +
processing mode
+ The processing mode defines how a JSON-LD document is processed. + By default, all documents are assumed to be conformat with + JSON-LD 1.0 [[!JSON-LD-20140116]]. By defining + a different version using the @version member in a + context, or via explicit API option, other processing modes + can be accessed. This specification defines extensions for the + json-ld-1.1 processing mode.
property
The IRI label of an edge in a linked data graph. See RDF predicate in [[RDF11-CONCEPTS]].
diff --git a/spec/latest/json-ld-api/index.html b/spec/latest/json-ld-api/index.html index 89908513c..8f0440e09 100644 --- a/spec/latest/json-ld-api/index.html +++ b/spec/latest/json-ld-api/index.html @@ -246,6 +246,14 @@

Features

transformations of JSON-LD documents. They are referred to as expansion and compaction, respectively.

+

JSON-LD 1.1 introduces new features that are + compatible with JSON-LD 1.0 [[!JSON-LD-20140116]], + but if processed by a JSON-LD 1.0 processor may produce different results. + In order to detect this JSON-LD 1.1 requires that the processing + mode be explicitly set to json-ld-1.1, either through the + processingMode API option, or using the + @version member within a context.

+

There are four major types of transformation that are discussed in this document: expansion, compaction, flattening, and RDF serialization/deserialization.

@@ -656,6 +664,12 @@

Overview

a combination of the two. Finally we process each context contained in the local context array as follows.

+

Unless specified using + processingMode API option, the first + context parsed which is a JSON object determines + sets the processing mode and + affects the behavior of expansion and compaction algorithms.

+

If context is a string, it represents a reference to a remote context. We dereference the remote context and replace context with the value of the @context key of the top-level object in the @@ -767,6 +781,20 @@

Algorithm

error has been detected and processing is aborted. +
  • If context has an @version key: +
      +
    1. If the associated value is not 1.1, + an invalid @version value + has been detected, and processing is aborted.
    2. +
    3. If processing mode + is not set, and json-ld-1.1 is not a prefix + of processing mode, + a processing mode conflict + error has been detected and processing is aborted.
    4. +
    5. Set processing mode, + to json-ld-1.1, if not already set.
    6. +
    +
  • If context has an @vocab key:
    1. Initialize value to the value associated with the @@ -794,6 +822,8 @@

      Algorithm

      error has been detected and processing is aborted.
  • +
  • Set processing mode, + to json-ld-1.0, if not already set.
  • Create a JSON object defined to use to keep track of whether or not a term has already been defined or currently being defined during recursion.
  • @@ -991,12 +1021,19 @@

    Algorithm

    or @language. Otherwise, an invalid container mapping has been detected and processing is aborted. +
  • If processingMode is json-ld-1.0 and the container value + is @id or @type, an + invalid container mapping + has been detected and processing is aborted.
  • Set the container mapping of definition to container.
  • If value contains the key @context:
      +
    1. If processingMode is json-ld-1.0, an + invalid term definition + has been detected and processing is aborted.
    2. Initialize context to the value associated with the @context key, which is treated as a local context.
    3. Invoke the Context Processing algorithm @@ -1022,6 +1059,9 @@

      Algorithm

    4. If value contains the key @nest:
        +
      1. If processingMode is json-ld-1.0, an + invalid term definition + has been detected and processing is aborted.
      2. Initialize nest to the value associated with the @nest key, which must be a string and must not be a keyword other than @nest. Otherwise, an @@ -1234,7 +1274,7 @@

        Algorithm

        @embed, @explicit, @omitDefault, or @requireAll) which are preserved through expansion. Special processing for a JSON-LD Frame is invoked when the - processingMode API option is set + processing mode is set to json-ld-1.1-expand-frame, indicated in the algorithm with the frame expansion flag.

        @@ -4053,7 +4093,7 @@

        The JsonLdOptions Type

        LoadDocumentCallback documentLoader = null; (object? or DOMString) expandContext = null; boolean produceGeneralizedRdf = true; - DOMString processingMode = "json-ld-1.1"; + DOMString processingMode = null; }; --> @@ -4076,8 +4116,10 @@

        The JsonLdOptions Type

        If set to true, the JSON-LD processor may emit blank nodes for triple predicates, otherwise they will be omitted.
        processingMode
        -
        If set to json-ld-1.1, the implementation has to produce - exactly the same results as the algorithms defined in this specification. +
        Sets the processing mode. + If set to json-ld-1.0 or json-ld-1.1, the + implementation must produce exactly the same results as the algorithms + defined in this specification. If set to another value, the JSON-LD processor is allowed to extend or modify the algorithms defined in this specification to enable application-specific optimizations. The definition of such @@ -4196,6 +4238,7 @@

        JsonLdErrorCode

        "invalid @index value", "invalid @nest value", "invalid @reverse value", + "invalid @version value", "invalid base IRI", "invalid container mapping", "invalid default language", @@ -4224,6 +4267,7 @@

        JsonLdErrorCode

        "loading document failed", "loading remote context failed", "multiple context link headers", + "processing mode conflict", "recursive context inclusion" }; --> @@ -4251,6 +4295,9 @@

        JsonLdErrorCode

        invalid @reverse value
        An invalid value for an @reverse member has been detected, i.e., the value was not a JSON object.
        +
        invalid @version value
        +
        The @version key was used in a context with + an out of range value.
        invalid base IRI
        An invalid base IRI has been detected, i.e., it is neither an absolute IRI nor null.
        @@ -4335,6 +4382,9 @@

        JsonLdErrorCode

        Multiple HTTP Link Headers [[!RFC5988]] using the http://www.w3.org/ns/json-ld#context link relation have been detected.
        +
        processing mode conflict
        +
        An attempt was made to change the processing mode which is + incompatible with the previous specified version.
        recursive context inclusion
        A cycle in remote context inclusions has been detected.
        @@ -4354,7 +4404,7 @@

        Security Considerations

        Changes since 1.0 Recommendation of 16 January 2014

        • The Expansion Algorithm - has a special processing mode, based on + has a special processing mode, based on the frame expansion flag, to enable content associated with JSON-LD frames, which may not otherwise be valid JSON-LD documents.
        • An expanded term definition can now have an @@ -4381,7 +4431,6 @@

          Open Issues

          The following is a list of open issues being worked on for the next release.

          -

          @@ -4392,9 +4441,10 @@

          Open Issues

          -

          +

          +

          diff --git a/spec/latest/json-ld-framing/index.html b/spec/latest/json-ld-framing/index.html index 224b32df2..ea2feabd1 100644 --- a/spec/latest/json-ld-framing/index.html +++ b/spec/latest/json-ld-framing/index.html @@ -1227,7 +1227,7 @@

          JsonLdProcessor

          frame and options with expandContext set to null - and processingMode set to "json-ld-framing-1.1-expand-frame". + and processingMode set to json-ld-1.1-expand-frame.
        • Set context to the value of @context from frame, if it exists, or to a new empty context, otherwise.
        • @@ -1443,6 +1443,12 @@

          application/ld-frame+json

          +
          +

          Security Considerations

          +

          Consider requirements from Self-Review Questionnaire: Security and Privacy.

          +

          See,

          +
          +
          diff --git a/spec/latest/json-ld/index.html b/spec/latest/json-ld/index.html index 277d24a95..665e18440 100644 --- a/spec/latest/json-ld/index.html +++ b/spec/latest/json-ld/index.html @@ -397,6 +397,12 @@

          Syntax Tokens and Keywords

          This keyword is described in .
          @nest
          Collects a set of nested properties within a node object.
          +
          @version
          + Used in a context definition to set the processing mode. + New features since JSON-LD 1.0 [[!JSON-LD-20140116]] described in this specification are + only available when processing mode has been explicitly set to + json-ld-1.1. +
          :
          The separator for JSON keys and values that use compact IRIs.
          @@ -711,7 +717,7 @@

          IRIs

          "@type": "@id" } ... - }**** + },**** ... "homepage": "http://manu.sporny.org/", ... @@ -829,7 +835,7 @@

          Specifying the Type

          ... ****"Restaurant": "http://schema.org/Restaurant", **** ****"Brewery": "http://schema.org/Brewery"**** - } + }, "@id": "http://example.org/places#BrewEats", ****"@type": [ "Restaurant", "Brewery" ]****, ... @@ -858,6 +864,37 @@

          Advanced Concepts

          the core functionality described above. The following section describes this advanced functionality in more detail.

          +
          +

          JSON-LD 1.1 Processing Mode

          + +

          New features defined in JSON-LD 1.1 are available + when the processing mode is set to json-ld-1.1. + This may be set using the @version member in a context + set to the value 1.1 as a number, or through an API option.

          + +
          +  
          +  
          + +

          The first context encountered when processing a + document determines the processing mode, + unless it is defined explicitly through an API option.

          + +

          Setting the processing mode explicitly + for JSON-LD 1.1 is necessary so that a JSON-LD 1.0 processor + does not attempt to process a JSON-LD 1.1 document and silently + produce different results.

          +
          +

          Base IRI

          @@ -1481,7 +1518,7 @@

          Advanced Context Usage

          starting with an @ character are to be avoided as they might be used as keyword in future versions of JSON-LD. Terms starting with an @ character that are not - JSON-LD 1.0 keywords are treated as any other term, i.e., + JSON-LD 1.1 keywords are treated as any other term, i.e., they are ignored unless mapped to an IRI. Furthermore, the use of empty terms ("") is not allowed as not all programming languages are able to handle empty JSON keys.

          @@ -2101,7 +2138,7 @@

          Reverse Properties

          --> -

          The @reverse keyword can also be used in +

          The @reverse keyword can also be used in expanded term definitions to create reverse properties as shown in the following example:

          @@ -2238,6 +2275,9 @@

          Scoped Contexts

          Scoping on @type is useful when common properties are used to relate things of different types, where the vocabularies in use within different entities calls for different context scoping. For example, `hasPart`/`partOf` may be common terms used in a document, but mean different things depending on the context.

          + +

          Scoped Contexts are a new feature in JSON-LD 1.1, requiring + processing mode set to json-ld-1.1

          @@ -2665,6 +2705,9 @@

          Node Identifier Indexing

          The interpretation of the data above is exactly the same as that in using a JSON-LD processor.

          + +

          Id maps are a new feature in JSON-LD 1.1, requiring + processing mode set to json-ld-1.1

          @@ -2712,6 +2755,9 @@

          Node Type Indexing

          been marked as an type map. The schema:Corporpation and schema:ProfessionalService keys will be interpreted as the @type property of the node object value.

          + +

          Type maps are a new feature in JSON-LD 1.1, requiring + processing mode set to json-ld-1.1

          @@ -2791,6 +2837,9 @@

          Nested Properties

          } --> + +

          Nested properties are a new feature in JSON-LD 1.1, requiring + processing mode set to json-ld-1.1

          @@ -3467,6 +3516,9 @@

          Context Definitions

          its value MUST be a absolute IRI, a compact IRI, a blank node identifier, a term, or null.

          +

          If the context definition has an @version key, + its value MUST be a number with the value 1.1.

          +

          The value of keys that are not keyword MUST be either an absolute IRI, a compact IRI, a term, a blank node identifier, a keyword, null, @@ -3728,7 +3780,6 @@

          Changes since 1.0 Recommendation of 16 January 2014

          Open Issues

          The following is a list of open issues being worked on for the next release.

          -

          @@ -3743,8 +3794,8 @@

          Open Issues

          -

          +

          diff --git a/test-suite/tests/error-manifest.jsonld b/test-suite/tests/error-manifest.jsonld index 8f4dcdcb8..85ba84095 100644 --- a/test-suite/tests/error-manifest.jsonld +++ b/test-suite/tests/error-manifest.jsonld @@ -382,6 +382,53 @@ "context": "error-n007-context.jsonld", "expect": "invalid @nest value", "option": {"processingMode": "json-ld-1.1"} + }, { + "@id": "#tp001", + "@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"], + "name": "Processing mode is implicitly json-ld-1.0", + "purpose": "If not specified using processingMode, processing mode is taken as json-ld-1.0", + "input": "error-p001-in.jsonld", + "expect": "invalid container mapping" + }, { + "@id": "#tp002", + "@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"], + "name": "processingMode json-ld-1.0 conflicts with @version: 1.1", + "purpose": "If not specified using processingMode, processing mode is taken as json-ld-1.0", + "input": "error-p002-in.jsonld", + "expect": "processing mode conflict", + "option": {"processingMode": "json-ld-1.0"} + }, { + "@id": "#tp003", + "@type": ["jld:NegativeEvaluationTest", "jld:ExpandTest"], + "name": "@version must be 1.1", + "purpose": "If @version is specified, it must be 1.1", + "input": "error-p003-in.jsonld", + "expect": "invalid @version value" + }, { + "@id": "#tp004", + "@type": ["jld:NegativeEvaluationTest", "jld:CompactTest"], + "name": "Processing mode is implicitly json-ld-1.0", + "purpose": "If not specified using processingMode, processing mode is taken as json-ld-1.0", + "input": "error-p004-in.jsonld", + "context": "error-p004-context.jsonld", + "expect": "invalid container mapping" + }, { + "@id": "#tp005", + "@type": ["jld:NegativeEvaluationTest", "jld:CompactTest"], + "name": "processingMode json-ld-1.0 conflicts with @version: 1.1", + "purpose": "If not specified using processingMode, processing mode is taken as json-ld-1.0", + "input": "error-p005-in.jsonld", + "context": "error-p005-context.jsonld", + "expect": "processing mode conflict", + "option": {"processingMode": "json-ld-1.0"} + }, { + "@id": "#tp006", + "@type": ["jld:NegativeEvaluationTest", "jld:CompactTest"], + "name": "@version must be 1.1", + "purpose": "If @version is specified, it must be 1.1", + "input": "error-p006-in.jsonld", + "context": "error-p006-context.jsonld", + "expect": "invalid @version value" } ] } diff --git a/test-suite/tests/error-p001-in.jsonld b/test-suite/tests/error-p001-in.jsonld new file mode 100644 index 000000000..81a736c75 --- /dev/null +++ b/test-suite/tests/error-p001-in.jsonld @@ -0,0 +1,10 @@ +{ + "@context": { + "@vocab": "http://example/", + "idmap": {"@container": "@id"} + }, + "idmap": { + "http://example.org/foo": {"label": "Object with @id "}, + "_:bar": {"label": "Object with @id _:bar"} + } +} \ No newline at end of file diff --git a/test-suite/tests/error-p002-in.jsonld b/test-suite/tests/error-p002-in.jsonld new file mode 100644 index 000000000..4caa4695e --- /dev/null +++ b/test-suite/tests/error-p002-in.jsonld @@ -0,0 +1,5 @@ +{ + "@context": { + "@version": 1.1 + } +} \ No newline at end of file diff --git a/test-suite/tests/error-p003-in.jsonld b/test-suite/tests/error-p003-in.jsonld new file mode 100644 index 000000000..63c70f63a --- /dev/null +++ b/test-suite/tests/error-p003-in.jsonld @@ -0,0 +1,5 @@ +{ + "@context": { + "@version": 1.0 + } +} \ No newline at end of file diff --git a/test-suite/tests/error-p004-context.jsonld b/test-suite/tests/error-p004-context.jsonld new file mode 100644 index 000000000..c699d9308 --- /dev/null +++ b/test-suite/tests/error-p004-context.jsonld @@ -0,0 +1,7 @@ +{ + "@context": { + "@vocab": "http://example/", + "ex": "http://example.org/", + "idmap": {"@container": "@id"} + } +} diff --git a/test-suite/tests/error-p004-in.jsonld b/test-suite/tests/error-p004-in.jsonld new file mode 100644 index 000000000..fe15d6377 --- /dev/null +++ b/test-suite/tests/error-p004-in.jsonld @@ -0,0 +1,5 @@ +[{ + "http://example/idmap": [ + {"http://example/label": [{"@value": "Object with @id "}], "@id": "http://example.org/foo"} + ] +}] \ No newline at end of file diff --git a/test-suite/tests/error-p005-context.jsonld b/test-suite/tests/error-p005-context.jsonld new file mode 100644 index 000000000..4caa4695e --- /dev/null +++ b/test-suite/tests/error-p005-context.jsonld @@ -0,0 +1,5 @@ +{ + "@context": { + "@version": 1.1 + } +} \ No newline at end of file diff --git a/test-suite/tests/error-p005-in.jsonld b/test-suite/tests/error-p005-in.jsonld new file mode 100644 index 000000000..9e26dfeeb --- /dev/null +++ b/test-suite/tests/error-p005-in.jsonld @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/test-suite/tests/error-p006-context.jsonld b/test-suite/tests/error-p006-context.jsonld new file mode 100644 index 000000000..63c70f63a --- /dev/null +++ b/test-suite/tests/error-p006-context.jsonld @@ -0,0 +1,5 @@ +{ + "@context": { + "@version": 1.0 + } +} \ No newline at end of file diff --git a/test-suite/tests/error-p006-in.jsonld b/test-suite/tests/error-p006-in.jsonld new file mode 100644 index 000000000..9e26dfeeb --- /dev/null +++ b/test-suite/tests/error-p006-in.jsonld @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/test-suite/tests/flatten-0004-in.jsonld b/test-suite/tests/flatten-0004-in.jsonld index 5768520b2..8499bfa08 100644 --- a/test-suite/tests/flatten-0004-in.jsonld +++ b/test-suite/tests/flatten-0004-in.jsonld @@ -13,7 +13,7 @@ "http://example.org/list1": { "@list": [ null ] }, "http://example.org/list2": { "@list": [ {"@value": null} ] }, "http://example.org/set1": { "@set": [ ] }, - "http://example.org/set1": { "@set": [ null ] }, + "http://example.org/set2": { "@set": [ null ] }, "http://example.org/set3": [ ], "http://example.org/set4": [ null ], "http://example.org/set5": "one item", diff --git a/test-suite/tests/flatten-0004-out.jsonld b/test-suite/tests/flatten-0004-out.jsonld index e1675517e..3e7c99476 100644 --- a/test-suite/tests/flatten-0004-out.jsonld +++ b/test-suite/tests/flatten-0004-out.jsonld @@ -1,66 +1,25 @@ [ { "@id": "http://example.org/id", - "http://example.com/mylist1": [ - { - "@list": [ - - ] - } - ], + "http://example.com/mylist1": [{"@list": []}], "http://example.com/mylist2": [ { - "@list": [ - { - "@value": "one item" - } - ] - } - ], - "http://example.com/myset2": [ - - ], - "http://example.com/myset3": [ - { - "@value": "v1" - } - ], - "http://example.org/list1": [ - { - "@list": [ - - ] - } - ], - "http://example.org/list2": [ - { - "@list": [ - - ] + "@list": [{"@value": "one item"}] } ], + "http://example.com/myset2": [], + "http://example.com/myset3": [{"@value": "v1"}], + "http://example.org/list1": [{"@list": []}], + "http://example.org/list2": [{"@list": []}], "http://example.org/property": [ { - "@list": [ - { - "@value": "one item" - } - ] + "@list": [{"@value": "one item"}] } ], - "http://example.org/set1": [ - - ], - "http://example.org/set3": [ - - ], - "http://example.org/set4": [ - - ], - "http://example.org/set5": [ - { - "@value": "one item" - } - ] + "http://example.org/set1": [], + "http://example.org/set2": [], + "http://example.org/set3": [], + "http://example.org/set4": [], + "http://example.org/set5": [{"@value": "one item"}] } ] \ No newline at end of file diff --git a/test-suite/tests/toRdf-0044-in.jsonld b/test-suite/tests/toRdf-0044-in.jsonld index 5768520b2..8499bfa08 100644 --- a/test-suite/tests/toRdf-0044-in.jsonld +++ b/test-suite/tests/toRdf-0044-in.jsonld @@ -13,7 +13,7 @@ "http://example.org/list1": { "@list": [ null ] }, "http://example.org/list2": { "@list": [ {"@value": null} ] }, "http://example.org/set1": { "@set": [ ] }, - "http://example.org/set1": { "@set": [ null ] }, + "http://example.org/set2": { "@set": [ null ] }, "http://example.org/set3": [ ], "http://example.org/set4": [ null ], "http://example.org/set5": "one item",