-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question/ unexpected behavior: Why does compaction sometimes expand and not remove a prefix? #495
Comments
@cboettig the In this case, the value is an object, not a literal. One of the object properties is This is described in Term Selection, but the language is fairly opaque, and the introduction could use a better english-language overview of what is going on. I'll keep this open as a reminder to add such language. |
@gkellogg thanks so much, that explains volumes. Yup, I think there were a few times in the documentation where I've puzzled as to whether the |
@gkellogg I am not understanding above nor did I understand what was described in Term Selection. What if you want the above to actually work and you want both prefixes to be stripped (with foo remaining foo and bar remaining bar) ? Then what do you have to do to the context to make that happen? In my case I have: as first arg to JsonLdProcessor.frame(output, JsonUtils.fromString(frame), opts)
and frame:
in the MetadataDictionary context I have:
Which results in:
but I want both those prefixes stripped.. How can I make that happen? If I remove the @type from the properties in context above then they do get stripped like I desire but I don't think I should be removing the type like that... In short I figure I'm doing something wrong so please advise.. |
@garpinc It seems that you are misunderstanding the role of
means:
About the second point above, notice that
So removing it from the context is probably the good solution. |
This explanation makes sense. I assume @gkellogg that you agree with this explanation? I was thinking that @type gives the author of content some indication what to put in the property and some validation facility? Since this is not the case how does an author know the type by looking at context... And how does a validator know what types are valid? |
@pchampin is correct, of course. the context is not used for validation, but expansion/compaction. It’s purpose is to provide a “context” for interpreting JSON. An OWL ontology, or ShEx/SHACL shape could be used for validation at the level of RDF, so JSON Schema at the level of JSON. the Structured Data Linter uses some of these techniques and other heuristics for validating JSON-LD. |
Ok.. I think that's pretty clear now... Perhaps some additional verbiage stating what you both said should be in the documentation because clearly what's there now wasn't clear to me.. This was a much better explanation.. |
Consider the following example:
Compaction under the identical context results in
bar
being expanded toex:bar
, butfoo
remainsfoo
. Why? To me this is unexpected: the context seems to unambiguously definebar
asex:bar
. I think this behavior has something to do withbar
taking a node value rather than a data value, but I fail to see why that matters. What does the user gain by having it calledex:bar
that wasn't clear when it was justbar
?This behavior is frustrating from the standpoint of a developer consuming JSON-LD with this kind of context structure, because I feel unable to predict whether the JSON files will use
bar
orex:bar
(and naturally I want to just usebar
, which is why it's explicitly mappedbar
to"@id": "ex:bar"
in the first place).Here's my example on Playground.
Thanks kindly for any clarification into this seemingly unexpected behavior that is no doubt more a problem of my understanding than algorithmic error!
The text was updated successfully, but these errors were encountered: