You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm running into (what seems like on the surface) a strange situation where documents with contexts containing an index can be parsed (e.g. expanded) correctly but cannot be round tripped back to the original form by compacting.
Consider the following example which comes directly from the JSON-LD specification here:
This is the correct expansion of the original document.
However, if I try to compact the expanded document using the original context, the JSON-LD playground returns the following error: jsonld.SyntaxError: Absolute IRI "schema:jobTitle" confused with prefix "schema".
Seems odd. Furthermore, if I use an absolute IRI as the error implies (i.e. "@index": "http://schema.org/jobTitle" instead of "@index": "schema:jobTitle"), the error isn't raised but the index isn't constructed correctly; the two athletes are sorted under "@none".
However, I can force it to compact the data to the original form using the following slightly modified context:
The problem with that, of course, is that the context is different from the original. However, the original context is technically still applicable since "job_title" alias cannot show up in the data (unless, of course, schema:jobTitle is used in a different way somewhere else in other data).
The JSON-LD playground was used to create the above examples, but its JSON-LD processor is not the only one that suffers from this issue; I originally happened upon it using a different JSON-LD processor.
I understand that I can avoid this issue by just using the modified context instead. However, I'm curious as to why it's even an issue in the first place. Why doesn't the compacting algorithm accept the index as defined in the original context (which can be used to expand the document correctly)? According to the error, it seems to expect an absolute IRI; if that's the case, why does the modified context work when "job_title" is also not an absolute IRI?
The text was updated successfully, but these errors were encountered:
mgberg
changed the title
Issue framing using a context with a property value index
Issue compacting using a context with a property value index
Sep 12, 2023
I'm running into (what seems like on the surface) a strange situation where documents with contexts containing an index can be parsed (e.g. expanded) correctly but cannot be round tripped back to the original form by compacting.
Consider the following example which comes directly from the JSON-LD specification here:
If I try to expand that JSON-LD, I get the following result:
This is the correct expansion of the original document.
However, if I try to compact the expanded document using the original context, the JSON-LD playground returns the following error:
jsonld.SyntaxError: Absolute IRI "schema:jobTitle" confused with prefix "schema".
Seems odd. Furthermore, if I use an absolute IRI as the error implies (i.e.
"@index": "http://schema.org/jobTitle"
instead of"@index": "schema:jobTitle"
), the error isn't raised but the index isn't constructed correctly; the two athletes are sorted under"@none"
.However, I can force it to compact the data to the original form using the following slightly modified context:
The problem with that, of course, is that the context is different from the original. However, the original context is technically still applicable since
"job_title"
alias cannot show up in the data (unless, of course,schema:jobTitle
is used in a different way somewhere else in other data).The JSON-LD playground was used to create the above examples, but its JSON-LD processor is not the only one that suffers from this issue; I originally happened upon it using a different JSON-LD processor.
I understand that I can avoid this issue by just using the modified context instead. However, I'm curious as to why it's even an issue in the first place. Why doesn't the compacting algorithm accept the index as defined in the original context (which can be used to expand the document correctly)? According to the error, it seems to expect an absolute IRI; if that's the case, why does the modified context work when
"job_title"
is also not an absolute IRI?The text was updated successfully, but these errors were encountered: