From c91473e6ccd00cf387390cc09142cc108544019e Mon Sep 17 00:00:00 2001 From: Ivan Martinez-Ortiz Date: Tue, 2 Aug 2022 19:39:36 +0200 Subject: [PATCH] Update references and clarify JSONPath constraints Update references pointing to the IETF WG documents, clarify some of the specification JSONPath constraints and provide crossreferences between documents. Fixes #257 --- xapi-profiles-about.md | 2 +- xapi-profiles-communication.md | 2 +- xapi-profiles-structure.md | 9 ++++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/xapi-profiles-about.md b/xapi-profiles-about.md index 71c3fc0..a6387c7 100644 --- a/xapi-profiles-about.md +++ b/xapi-profiles-about.md @@ -243,7 +243,7 @@ even if there no requirement in a given area. **JSON-LD**: [JSON-LD](https://json-ld.org) turns JSON into Linked Data, making it easy to use with Linked Data tools and integrate with other datasets. -**JSONPath**: [JSONPath](http://goessner.net/articles/JsonPath/index.html#e2) provides a way to address parts of JSON documents using a `JSONPath expression`. +**JSONPath**: [JSONPath](https://datatracker.ietf.org/doc/draft-ietf-jsonpath-base/05/) provides a way to address parts of JSON documents using a `JSONPath expression`. This specification proposes some [constraints](./xapi-profiles-structure.md#jsonpath-constraints) to the possible JSONPath expressions. **Language Map**: A Language Map expresses multiple language-specific values at once. While used in the xAPI specification essentially identically, the controlling specification is [JSON-LD Language Maps](https://www.w3.org/TR/json-ld/#language-maps). diff --git a/xapi-profiles-communication.md b/xapi-profiles-communication.md index 9d68a63..d56610a 100644 --- a/xapi-profiles-communication.md +++ b/xapi-profiles-communication.md @@ -273,7 +273,7 @@ function follows_rule(statement, rule): function apply_jsonpath(statement, path): The definition of this is beyond the scope of this document, but it follows the JSONPath specification as constrained by the requirements in this - specification. If a single value is found in the Statement matching the + specification (xapi-profiles-structure.md#jsonpath-constraints). If a single value is found in the Statement matching the path, it is returned in an array (even if the single value is already an array). If multiple values are found, they are returned in an array. If no values are found, an empty array is returned. diff --git a/xapi-profiles-structure.md b/xapi-profiles-structure.md index 5ef4399..3516ee2 100644 --- a/xapi-profiles-structure.md +++ b/xapi-profiles-structure.md @@ -509,10 +509,13 @@ A Profile Validator validating Statements MUST validate the Statement Template R When validating a Statement for Statement Template Rules, `contextActivities` normalization MUST have already been performed as described in the Experience API specification. That is, singleton objects MUST be replaced by arrays of length one. -The syntax and behavior of JSONPath is described at http://goessner.net/articles/JsonPath/index.html#e2. In addition, the following requirements, clarifications, and additions apply: -* Filter and script expressions MUST NOT be used. + +#### JSONPath Constraints + +The syntax and behavior of JSONPath is described at https://datatracker.ietf.org/doc/draft-ietf-jsonpath-base/05/. In addition, the following requirements, clarifications, and additions apply: +* Filter (`?()`) and script (`()`) expressions MUST NOT be used. * The union operator (a comma) may be used inside array or child expressions, so the result is the union on each expression being used separately. -* The legal values in an array or child expression are: strings (child expressions), non-negative integers (array expressions), the star character `*` representing all children/members, and unions of these as described above. +* The legal values in an array or child expression are: strings (child expressions), non-negative integers (array expressions), the star character `*` representing all children/members, and unions of these as described above. The array slice operator MUST NOT be used. * Any two or more legal JSONPath expressions, joined together by the pipe character `|`, optionally with whitespace around the pipe, are also considered a legal JSONPath expression. The value of this expression is all the values returned by each expression individually, flattened (that is, if one expression returns N values and another returns a single value, the combination returns N+1 values, not two values). #### Example