为什么在扩展之前,id的相对IRI中的基本前缀会缩短?

use*_*443 3 base-url json-ld

我有一个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"
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

然后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 .
Run Code Online (Sandbox Code Playgroud)

我无法理解为什么两条线的ID都是正确的<http://example.com/2>而不是<http://example.com/base#auth-1/2>.为什么缩短基本前缀?我可以改变什么以避免这种情况?

uno*_*nor 7

@base遵循RFC 3986的建立基本URI,其中说明(大胆强调我的):

如果从URI引用获取基URI,则必须将该引用转换为绝对形式,并在将其用作基本URI之前剥离任何片段组件.

所以你的

"@base": "http://example.com/base#auth-1/",
Run Code Online (Sandbox Code Playgroud)

将导致此基础IRI:

http://example.com/base
Run Code Online (Sandbox Code Playgroud)

如果你指定"lid": "#auth-1/2"而不是"lid": "2",你最终会http://example.com/base#auth-1/2.

或者,您可以为这些值定义前缀,例如

"foobar": "http://example.com/base#auth-1/"
Run Code Online (Sandbox Code Playgroud)

并使用

"lid": "foobar:2"
Run Code Online (Sandbox Code Playgroud)