有两个使用W3C pyRdfa提取器的SPARQL查询。
1:此查询产生预期结果:
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?Content ?Author
FROM <http://www.w3.org/2007/08/pyRdfa/extract?uri=http://www.3kbo.com/examples/rdfa/simple.html>
WHERE {
?s dc:creator ?o .
?s dc:title ?Content .
?o foaf:name ?Author .
}
ORDER BY ?Content
结果如下:
http://www.sparql.org/sparql?query=PREFIX+dc%3A+%3Chttp%3A%2F%2Fpurl.org%2Fdc%2Felements%2F1.1%2F%3E%0D%0APREFIX+foaf%3A+%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2F%3E%0D%0ASELECT+%3FContent+%3FAuthor%0D%0AFROM+%3Chttp%3A%2F%2Fwww.w3.org%2F2007%2F08%2FpyRdfa%2Fextract%3Furi%3Dhttp%3A%2F%2Fwww.3kbo.com%2Fexamples%2Frdfa%2Fsimple.html%3E%0D%0AWHERE+{%0D%0A%09%3Fs+dc%3Acreator+%3Fo+.%0D%0A%09%3Fs+dc%3Atitle+%3FContent+.%0D%0A%09%3Fo+foaf%3Aname+%3FAuthor+.%0D%0A%09}%0D%0AORDER+BY+%3FContent&default-graph-uri=&output=text&stylesheet=%2Fxml-to-html.xsl
2:此查询不会产生与上述类似的结果:
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?Content ?Author
FROM <http://www.w3.org/2007/08/pyRdfa/extract?uri=http://www.w3.org/2013/Talks/0902-Lisbon-IH/>
WHERE {
?s dc:author ?o .
?s dc:title ?Content .
?o foaf:name ?Author .
}
ORDER BY ?Content
结果如下:
http://www.sparql.org/sparql?query=PREFIX+dc%3A+%3Chttp%3A%2F%2Fpurl.org%2Fdc%2Felements%2F1.1%2F%3E%0D%0APREFIX+foaf%3A+%3Chttp%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2F%3E%0D%0ASELECT+%3FContent+%3FAuthor%0D%0AFROM+%3Chttp%3A%2F%2Fwww.w3.org%2F2007%2F08%2FpyRdfa%2Fextract%3Furi%3Dhttp%3A%2F%2Fwww.w3.org%2F2013%2FTalks%2F0902-Lisbon-IH%2F%3E%0D%0AWHERE+{%0D%0A%09%3Fs+dc%3Aauthor+%3Fo+.%0D%0A%09%3Fs+dc%3Atitle+%3FContent+.%0D%0A%09%3Fo+foaf%3Aname+%3FAuthor+.%0D%0A%09}%0D%0AORDER+BY+%3FContent%0D%0A&default-graph-uri=&output=text&stylesheet=%2Fxml-to-html.xsl
为什么#2无法产生像#1这样的结果?
#2的SPARQL代码是否有错误?
或者与#1和#2相关的RDFa结构是否存在语义差异?
我在示例中使用了这个pyRdfa版本:
http://www.w3.org/2007/08/pyRdfa/extract?uri=
不使用偶尔会混淆SPARQL处理器的版本:
http://www.w3.org/2012/pyRdfa/extract?uri=
TY指导。
答案 0 :(得分:5)
http://www.w3.org/2013/Talks/0902-Lisbon-IH/
使用RDFa 1.1,但http://www.w3.org/2007/08/pyRdfa/extract?uri=
支持RDFa 1.0。
您使用的是:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:xhv="http://www.w3.org/1999/xhtml/vocab#"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
>
<rdf:Description rdf:about="talk:">
<xhv:icon rdf:resource="http://www.w3.org/2001/sw/favicon-sw.png"/>
<xhv:stylesheet rdf:resource="http://www.w3.org/2006/02/charter-style.css"/>
<xhv:stylesheet rdf:resource="http://www.w3.org/Guide/pubrules-style.css"/>
<xhv:copyright rdf:resource="http://creativecommons.org/licenses/by-nd/3.0/"/>
</rdf:Description>
</rdf:RDF>
即。没有三重奏。这是因为源使用RDFa 1.1 @prefix
属性声明前缀,这在RDFa 1.0中不存在。因此,大多数缩写的URL根据较旧的解析器而被破坏。
使用newer parser,您会发现更多三元组,包括:
...
talk: a ore:ResourceMap;
dc:author <http://www.ivan-herman.net/foaf#me>;
dc:date "$Date: 2013-08-27 07:51:24 $";
dc:title "Introduction to Linked Open Data";
ore:describes <http://www.w3.org/2012/0902-Lisbon-IH/#talk> .
...
您正在寻找的是什么。
然而
作为美中不足的最后一个文件,这两个文件正在使用不同版本的都柏林核心命名空间。默认情况下,RDFa 1.1将dc
前缀绑定到更新的http://purl.org/dc/terms/
,这会抛出您的查询。
所以试试:
PREFIX dc: <http://purl.org/dc/terms/> # FIXED dc
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?Content ?Author
# Use RDFa 1.1 parser
FROM <http://www.w3.org/2012/pyRdfa/extract?uri=http://www.w3.org/2013/Talks/0902-Lisbon-IH/>
WHERE {
?s dc:author ?o .
?s dc:title ?Content .
?o foaf:name ?Author .
}
ORDER BY ?Content
Tada,结果。