SPARQL 查询:我如何只得到一个文字或字符串作为结果? [英] SPARQL Query: How I get only a literal or string as result?

查看:35
本文介绍了SPARQL 查询:我如何只得到一个文字或字符串作为结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

数据:

<untitled-ontology-5:OperationName rdf:datatype="http://www.w3.org/2001/XMLSchema#string">
  Adhesive Curing
</untitled-ontology-5:OperationName>

SPARQL 查询:

PREFIX rdf:<http://wwww.semanticweb.org/ontologies/2012/7/9/untitled-ontology-5#>
SELECT ?object
WHERE { ?subject  rdf:OperationName ?object .       
}

结果:

Adhesive Curing^^http://www.w3.org/2001/XMLSchema#string 

<小时>

我的问题:

SPARQL 查询的结果不是我想要的结果.正确的结果应该只包含没有 URI 部分的文字/字符串.我想创建以下结果:

The result of the SPARQL Query is not the result what I wanted. The right result should contain only the Literal/String without the URI-part. I'd like to create the following result:

正确结果:

Adhesive Curing

推荐答案

您需要使用 STR() 函数来检索文字的词法标签:

You need to use the STR() function to retrieve the lexical label of your literal:

查询:

SELECT (str(?object) as ?label) 
WHERE { ?subject rdf:OperationName ?object . }

这篇关于SPARQL 查询:我如何只得到一个文字或字符串作为结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆