Closed ewintr closed 2 years ago
@ewintr,
The two examples you provided have slightly different semantics.
lei:
is not a prefix anymore, but a valid part of an absolute identifier. The subsequent compaction using the provided context gets confused and throws an error. By the way, I tried the same example on JSON-LD playground, and it produces the same error.In order to get the flattening working, you should either 1) keep the context in the document, so that the prefix is visible to the algorithm, and then pass the context for compaction, as in your second example; or 2) pass the ID in the full form as urn:lei:12345
instead of lei:12345
.
Oh, this is very helpful. I now understand better where I went wrong. Thank you for explaining!
I am a bit confused by the following behavior. This will expand the
lei
prefix as expected:Result:
But this will throw an error "Error when flattening JSON-LD document: IRI confused with prefix: Absolute IRI lei:12345 confused with prefix lei":
See playground1 and playground2
I can see that there is code in the
Context
type to explicitly forbid this type of prefix, but should it not be allowed? Trying the same example on the json-ld.org playground also works fine.