为什么在扩展之前缩短了 id 的相对 IRI 中的基本前缀?
Why is the base prefix in a relative IRI for an id shortened before expansion?
我有一个 JSON-LD 文档,其中基本前缀没有像我预期的那样扩展,而是先缩短到它的根,然后附加 @id
数据:
{
"@context": {
"tag": "@type",
"@base": "http://example.com/base#auth-1/",
"Line": "lit:Line",
"load": "book:load",
"book": "http://gerastree.at/auth-1/",
"lnum": "lit:lnum",
"lline": {
"@language": "deu",
"@id": "lit:lines"
},
"lit": "http://gerastree.at/lit_2014#",
"lid": "@id"
},
"loadid": "loadIDstring",
"load": [
{
"tag": "Line",
"lnum": 1,
"lline": "asdf1",
"lid": "1"
},
{
"tag": "Line",
"lnum": 2,
"lline": "asdf2",
"lid": "2"
}
]
}
RIOT(或游乐场)然后给出:
riot --syntax=jsonld --output=turtle lines.jsonld
@prefix lit: <http://gerastree.at/lit_2014#> .
@prefix book: <http://gerastree.at/auth-1/> .
_:b0 book:load <http://example.com/1> ;
book:load <http://example.com/2> .
<http://example.com/1>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> lit:Line ;
lit:lines "asdf1"@deu ;
lit:lnum 1 .
<http://example.com/2>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> lit:Line ;
lit:lines "asdf2"@deu ;
lit:lnum 2 .
我无法理解为什么这两行的id只是<http://example.com/2>
而不是<http://example.com/base#auth-1/2>
。为什么基础前缀被缩短了?我可以改变什么来避免这种情况?
@base
follows RFC 3986’s Establishing a Base URI,它说(大胆强调我的):
If the base URI is obtained from a URI reference, then that reference must be converted to absolute form and stripped of any fragment component prior to its use as a base URI.
所以你的
"@base": "http://example.com/base#auth-1/",
将导致此基础 IRI:
http://example.com/base
如果您指定 "lid": "#auth-1/2"
而不是 "lid": "2"
,您最终会得到 http://example.com/base#auth-1/2
。
或者,您可以为这些值定义一个前缀,例如
"foobar": "http://example.com/base#auth-1/"
并使用
"lid": "foobar:2"
我有一个 JSON-LD 文档,其中基本前缀没有像我预期的那样扩展,而是先缩短到它的根,然后附加 @id
数据:
{
"@context": {
"tag": "@type",
"@base": "http://example.com/base#auth-1/",
"Line": "lit:Line",
"load": "book:load",
"book": "http://gerastree.at/auth-1/",
"lnum": "lit:lnum",
"lline": {
"@language": "deu",
"@id": "lit:lines"
},
"lit": "http://gerastree.at/lit_2014#",
"lid": "@id"
},
"loadid": "loadIDstring",
"load": [
{
"tag": "Line",
"lnum": 1,
"lline": "asdf1",
"lid": "1"
},
{
"tag": "Line",
"lnum": 2,
"lline": "asdf2",
"lid": "2"
}
]
}
RIOT(或游乐场)然后给出:
riot --syntax=jsonld --output=turtle lines.jsonld
@prefix lit: <http://gerastree.at/lit_2014#> .
@prefix book: <http://gerastree.at/auth-1/> .
_:b0 book:load <http://example.com/1> ;
book:load <http://example.com/2> .
<http://example.com/1>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> lit:Line ;
lit:lines "asdf1"@deu ;
lit:lnum 1 .
<http://example.com/2>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> lit:Line ;
lit:lines "asdf2"@deu ;
lit:lnum 2 .
我无法理解为什么这两行的id只是<http://example.com/2>
而不是<http://example.com/base#auth-1/2>
。为什么基础前缀被缩短了?我可以改变什么来避免这种情况?
@base
follows RFC 3986’s Establishing a Base URI,它说(大胆强调我的):
If the base URI is obtained from a URI reference, then that reference must be converted to absolute form and stripped of any fragment component prior to its use as a base URI.
所以你的
"@base": "http://example.com/base#auth-1/",
将导致此基础 IRI:
http://example.com/base
如果您指定 "lid": "#auth-1/2"
而不是 "lid": "2"
,您最终会得到 http://example.com/base#auth-1/2
。
或者,您可以为这些值定义一个前缀,例如
"foobar": "http://example.com/base#auth-1/"
并使用
"lid": "foobar:2"