I have a JSON-LD document in which the base prefix is not expanded as I expect but shortened first to its root and then the @id data is appended:
{
"@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 (or the playground) gives then:
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 .
I cannot understand why the ids of the two lines are just <http://example.com/2> and not <http://example.com/base#auth-1/2>. Why is the base prefix shortened? What can I change to avoid this?
@base follows RFC 3986’s Establishing a Base URI, which says (bold emphasis mine):
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.
So your
"@base": "http://example.com/base#auth-1/",
will result in this base IRI:
http://example.com/base
If you specify "lid": "#auth-1/2" instead of "lid": "2", you end up with http://example.com/base#auth-1/2.
Alternatively, you could define a prefix for these values, like
"foobar": "http://example.com/base#auth-1/"
and use
"lid": "foobar:2"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With