我有一个用例是在 Github 页面中托管一组文件(具有不同序列化格式的相同 RDF 内容,例如 RDF/XML、Turtle 和 JSON-LD),并使用w3id URL作为永久标识符。
此外,我想在该永久 URL 上进行内容协商。如果我将文件托管在 Apache 服务器中,这将是微不足道的,但不幸的是 Github 页面不支持内容协商。所以我想看看我可以在多大程度上使用 URL 重写规则来做到这一点。
所以这个想法类似于以下内容。
GET http://w3id.org/foo -- redirect to --> http://foo.git.io/content.ttl
Accept: text/turtle
GET http://w3id.org/foo -- redirect to --> http://foo.git.io/content.jsonld
Accept: application/ld+json
Run Code Online (Sandbox Code Playgroud)
目前我的规则如下所示。
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_ACCEPT} ^.*application/rdf\+xml.*
RewriteRule ^foaf$ http://nandana.github.io/foaf/card.rdf [R=303,L]
RewriteCond %{HTTP_ACCEPT} ^.*text/turtle.*
RewriteRule ^foaf$ http://nandana.github.io/foaf/card.ttl [R=303,L]
RewriteCond %{HTTP_ACCEPT} ^.*application/ld\+json.*
RewriteRule ^foaf$ http://nandana.github.io/foaf/card.jsonld [R=303,L]
RewriteRule ^foaf$ http://nandana.github.io/foaf/card.html [R=303,L]
Run Code Online (Sandbox Code Playgroud)
尽管这适用于大多数情况,但在某些极端情况下会中断。例如,如果有一个像下面这样的接受头
Accept: application/rdf+xml;q=0.9,text/turtle
Run Code Online (Sandbox Code Playgroud)
这将返回 application/rdf+xml (因为第一个规则匹配),尽管根据内容协商它应该返回乌龟。有谁知道改进规则来处理这种极端情况的方法?
apache mod-rewrite content-negotiation github-pages linked-data
TL; DR
如果我有一个像JSON文件
{
"policyid": "http://example.com/policy:0099",
"policytype": "http://www.w3.org/ns/odrl/2/Set"
}
Run Code Online (Sandbox Code Playgroud)
我想要一个类似的JSON-LD文档
{
"@context": {
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"policytype": { "@id": "rdf:type", "@type": "@id" }
}
"@id" : "http://example.com/policy:0099",
"policytype": "http://www.w3.org/ns/odrl/2/Set"
}
Run Code Online (Sandbox Code Playgroud)
是否可以不将名称/值对{{policyid":" http://example.com/policy:0099 "} 更改为{"@ id ":" http://example.com/policy:0099 "而是在上下文中说出"policyid" - >"@ id".
{
"@context": {
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"policytype": { "@id": "rdf:type", "@type": "@id" },
#### something here that says "policyid" -> "@id"
}
"policyid" : "http://example.com/policy:0099",
"policytype": "http://www.w3.org/ns/odrl/2/Set"
}
Run Code Online (Sandbox Code Playgroud)
我正在通过规范示例,但无法找到如何做到这一点.
更多背景
假设我们有一个具有RDF规范和JSON编码的模型,例如ODRL 2.1 Ontology和ODRL Version 2.1 JSON Encoding. …
比如在RDF数据集中,有一组值,范围从0到100(例如,百分比).我想计算给定范围内的值的数量,例如,100 - 90 | 90 - 80 | ...... | 10 - 0.我期望的输出如下所示:
???????????????????????????
? Range ? Count ?
???????????????????????????
? 100 >= x < 90 ? 4521 ?
? 90 >= x < 80 ? 650 ?
? ... ? ... ?
? 10 >= x <= 0 ? 2650 ?
???????????????????????????
Run Code Online (Sandbox Code Playgroud)
我目前正在使用SPARQL子查询和过滤器来获得解决方案.但这似乎是一个常见的用例,我的直觉告诉我应该有更好的方法来做到这一点.是否有更好(或更有效)的方法来达到这个答案?
目前的解决方案如下所示.
PREFIX dqv: <http://www.w3.org/ns/dqv#>
select distinct ?count90_100 ?count80_90 ?count10_0 where {
?m a dqv:QualityMeasurement .
{ select count(?m) as ?count90_100 where { ?m dqv:value ?value FILTER …Run Code Online (Sandbox Code Playgroud) linked-data ×2
rdf ×2
apache ×1
github-pages ×1
json ×1
json-ld ×1
mod-rewrite ×1
optimization ×1
sparql ×1