w3c / json-ld-api

JSON-LD 1.1 Processing Algorithms and API Specification
https://w3c.github.io/json-ld-api/
Other
76 stars 29 forks source link

missing instructions in Node Map generation #549

Open pchampin opened 1 year ago

pchampin commented 1 year ago

I believe that an instruction is missing from step 6.10 of Node Map Generation, namely:

before recursively invoking the algorithm. Indeed, in step 2 of the invoked algorithm, that entry is assumed to already exist:

Reference the map which is the value of the active graph entry of node map")

(edited wrong markup, which made the suggested sentence potentially harder to understand)

gkellogg commented 1 year ago

Sorry, a bit confused. Step 6.10 is the following:

6.10) If _element+ has an @graph entry, recursively invoke this algorithm passing the value of the @graph entry for element, node map, and id for active graph before removing the @graph entry from element.

In fact, when searching the document (both TR and ED), I can't find a sentence "if node map does not contain an id entry, create one and initialize its value to an empty map".

The algorithm takes node map as an input argument, so it definitely must already exist. The places which recursively invoke the algorithm pass the existing node map, so I don't see the specific issue.

pchampin commented 1 year ago

The sentence I wrote ("if node map does not contain an id entry...") is what I suggest to add to step 6.10 . So indeed, it is currently not in the spec :-)

Of course node map always exists. What does not always exist, when entering 6.10, is an entry in node map whose key is id. When the algorithm is recursively invoked, passing node map and passing id for active graph, this entry is assumed to exist at step 2.

By adding the suggested sentence in 6.10 before the recursive invocation, we ensure that this assumption in the invoked step 2 is satisfied.