SPARQL:一个查询工作;类似的查询失败

SPARQL:一个查询工作;类似的查询失败,sparql,Sparql,有两个使用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/example

有两个使用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
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
为什么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=
请点击此处获取指导。

http://www.w3.org/2013/Talks/0902-Lisbon-IH/ 但是,使用RDFA1.1http://www.w3.org/2007/08/pyRdfa/extract?uri= 支持RDFA1.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将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

,结果。

好的!泰。因此,对于2,我更新了查询以使用FROM Still,没有结果。如果我单独运行提取器,我会看到6个三元组,其中4个满足SPARQL变量。您看到SPARQL查询有问题吗?您注意到我的编辑提到dc前缀问题了吗?我提供了完整的工作查询。
<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>
...
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> .
...
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