N-triples IRI前缀jena

时间:2017-03-23 03:08:12

标签: jena prefix n-triples iri

我想使用前缀来表示这个nt文件:

<www.test.com/a/yan-dang-shan> <www.test.com/a/zhongwenming> <www.test.com/a/yan-dang-shan> .
<www.test.com/a/yan-dang-shan> <http://www.w3.org/2000/01/rdf-schema#label> "a" .
<www.test.com/a/zhongwenming> <http://www.w3.org/2000/01/rdf-schema#label> "b" .
<www.test.com/a/yan-dang-shan> <http://www.w3.org/2000/01/rdf-schema#label> "c" .

我写入新的nt文件是:

@prefix sp: <www.test.com/a/> .
<sp:yan-dang-shan> <sp:zhongwenming> <sp:yan-dang-shan> .
<sp:yan-dang-shan> <http://www.w3.org/2000/01/rdf-schema#label> "a" .
<sp:zhongwenming> <http://www.w3.org/2000/01/rdf-schema#label> "b" .
<sp:yan-dang-shan> <http://www.w3.org/2000/01/rdf-schema#label> "c" .

但是当我在cmd中使用它来sparql时:

SELECT ?x ?y ?z
WHERE
{ ?x ?y ?z . }  

cmd中显示错误:

D:\>sparql --data=ceshi.nt --query=ceshi.rq
11:01:42 ERROR riot                 :: [line: 1, col: 1 ] Expected BNode or IRI:
 Got: [DIRECTIVE:prefix]
Failed to load data

我也试过这个:

@prefix sp: <www.test.com/a/> .
sp:yan-dang-shan sp:zhongwenming sp:yan-dang-shan .
sp:yan-dang-shan <http://www.w3.org/2000/01/rdf-schema#label> "a" .
sp:zhongwenming <http://www.w3.org/2000/01/rdf-schema#label> "b" .
sp:yan-dang-shan <http://www.w3.org/2000/01/rdf-schema#label> "c" .

但它报告了同样的错误,我不知道如何解决它。

我该如何修改以使其成功?

任何帮助将不胜感激。 谢谢!

1 个答案:

答案 0 :(得分:0)

N-triples没有前缀。

Turtle有前缀。尝试将您的数据放在扩展名为“.ttl”的文件中。

您可以使用命令行工具curl测试数据。