-
Notifications
You must be signed in to change notification settings - Fork 36
Description
Summary
"Create term definition" algorithm has a step that replaces schema part of an absolute IRI to another IRI (the IRI mapping for the term that equals to the schema string).
This causes "http://example.com" to be replaced to "schema://hello//example.com" (in example above), but this is unexpected for me.
I'm not sure if this is a bug, but I want to know this is intended behavior or not.
If this is not intended, step 14.2 in JSON-LD-API 1.0 and step 17.2 in JSON-LD-API 1.1 (TR) should be like this:
"If term is a compact IRI and term's prefix has a term definition in active context, set the IRI mapping of ...".
Details
Create term definition has the steps below:
- If term contains a colon:
- If term is a compact IRI with a prefix that is a key in local context, recursively create term definition for the prefix.
- If term's prefix has a term definition in active context, concatenate IRI mapping for the prefix and the term's suffix.
- Otherwise, term is an absolute IRI or blank node identifier. Use it as is.
For exact definitions, see step 14 in JSON-LD-API 1.0 §6.2 Create Term Definition, and JSON-LD-API 1.1 §4.2 Create Term Definition step 17.
Lines 1405 to 1422 in 4725397
| <li> | |
| Otherwise if the <var>term</var> contains a colon (<code>:</code>): | |
| <ol> | |
| <li>If <var>term</var> is a <a>compact IRI</a> with a | |
| <a>prefix</a> that is a <a>member</a> in <var>local context</var> | |
| a dependency has been found. Use this algorithm recursively passing | |
| <var>active context</var>, <var>local context</var>, the | |
| <a>prefix</a> as <var>term</var>, and <var>defined</var>.</li> | |
| <li>If <var>term</var>'s <a>prefix</a> has a | |
| <a>term definition</a> in <var>active context</var>, set | |
| the <a>IRI mapping</a> of <var>definition</var> to the result of | |
| concatenating the value associated with the <a data-lt="prefix">prefix's</a> | |
| <a>IRI mapping</a> and the <var>term</var>'s <var>suffix</var>.</li> | |
| <li>Otherwise, <var>term</var> is an <a>absolute IRI</a> or | |
| <a>blank node identifier</a>. Set the <a>IRI mapping</a> | |
| of <var>definition</var> to <var>term</var>.</li> | |
| </ol> | |
| </li> |
The problem is the second substep, "If term's prefix has a term definition in active context, ...".
This step replaces prefix of a compact IRI (for example xsd:dateTime to http://www.w3.org/2001/XMLSchema#dateTime), which is expected behavior.
However, this condition does not require term to be a compact IRI (which is required in the previous substep), and this causes an absolute IRI to be replaced if the schema (such as http) has a corresponding term definition.
For example, http://example.com is replaced to schema://hello//example.com in such cases.
I think the second substep should be like this: "If term is a compact IRI and term's prefix has a term definition in active context, set the IRI mapping of ...".
Example
input
Attempt to associate "2000" value to the absolute IRI http://example.com.
{
"@context": {
"http": "schema://hello",
"http://example.com": {
"@type": "http://type"
}
},
"http://example.com": "2000"
}actual output
Absolute IRI http://example.com in input document is replaced to schema://hello//example.com, as if it was a compact IRI.
[
{
"schema://hello//example.com": [
{
"@type": "http://type",
"@value": "2000"
}
]
}
]expected
http://example.com is preserved even when a term http is expandable to another IRI, because http://example.com is not a compact IRI.
[
{
"http://example.com": [
{
"@type": "http://type",
"@value": "2000"
}
]
}
]