Rasqal 的命令行查询工具就是这样做的roqet
;见http://librdf.org/rasqal/roqet.html
。
或在线访问http://triplr.org/query
。
用示例编辑它的工作原理和包装:
Rasqal 示例包:
让我们尝试从https://wiki.blazegraph.com/wiki/index.php/Quick_Start教程执行“hello world”查询。
这是示例data.ttl
文件:
PREFIX : <http://blazegraph.com/>
PREFIX schema: <http://schema.org/>
:systap a schema:Organization ;
schema:owns :blazegraph .
:blazegraph a schema:Product ;
schema:brand :systap;
:productOf <http://systap.com/>;
:implements <http://rdf4j.org>,<http://blueprints.tinkerpop.com> .
示例“hello world”Sparql 查询:
$ roqet -i sparql -e 'SELECT * WHERE { <http://blazegraph.com/blazegraph> ?p ?o }' -D data.ttl
roqet: Running query 'SELECT * WHERE { <http://blazegraph.com/blazegraph> ?p ?o }'
roqet: Query has a variable bindings result
row: [p=uri<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>, o=uri<http://schema.org/Product>]
row: [p=uri<http://schema.org/brand>, o=uri<http://blazegraph.com/systap>]
row: [p=uri<http://blazegraph.com/productOf>, o=uri<http://systap.com/>]
row: [p=uri<http://blazegraph.com/implements>, o=uri<http://rdf4j.org>]
row: [p=uri<http://blazegraph.com/implements>, o=uri<http://blueprints.tinkerpop.com>]
roqet: Query returned 5 results
甚至更通用
$ roqet -i sparql -e 'SELECT * WHERE { ?s ?p ?o }' -D data.ttl | xsel -b
roqet: Running query 'SELECT * WHERE { ?s ?p ?o }'
roqet: Query has a variable bindings result
row: [s=uri<http://blazegraph.com/systap>, p=uri<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>, o=uri<http://schema.org/Organization>]
row: [s=uri<http://blazegraph.com/systap>, p=uri<http://schema.org/owns>, o=uri<http://blazegraph.com/blazegraph>]
row: [s=uri<http://blazegraph.com/blazegraph>, p=uri<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>, o=uri<http://schema.org/Product>]
row: [s=uri<http://blazegraph.com/blazegraph>, p=uri<http://schema.org/brand>, o=uri<http://blazegraph.com/systap>]
row: [s=uri<http://blazegraph.com/blazegraph>, p=uri<http://blazegraph.com/productOf>, o=uri<http://systap.com/>]
row: [s=uri<http://blazegraph.com/blazegraph>, p=uri<http://blazegraph.com/implements>, o=uri<http://rdf4j.org>]
row: [s=uri<http://blazegraph.com/blazegraph>, p=uri<http://blazegraph.com/implements>, o=uri<http://blueprints.tinkerpop.com>]
roqet: Query returned 7 results