2

我创建了这个查询:

PREFIX VB: <http://VBnet#>
SELECT  ?x ?y
WHERE 
{
  ?x VB:HasName ?y
}     

HasName 是一种数据类型属性。当我在 Protege 中运行此查询时,系统只显示没有任何数据类型属性值的主题。mwans ?y 为空。另外,当我在耶拿系统中运行时,只显示:(字符串)

如何查看数据类型属性的值?y

4

2 回答 2

1

这取决于 RDF 文档中包含的数据。如果这些值是类型化的文字,那么您可以解析 SPARQL 结果集并询问绑定到 ?y 变量的值的数据类型。如果值以不符合 RDF 的方式(例如 html)呈现,则数据类型可能不会出现。否则你会看到这样的东西:

<sparql xmlns="http://www.w3.org/2005/sparql-results#"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xsi:schemaLocation="http://www.w3.org/2001/sw/DataAccess/rf1/result2.xsd">
<head>
<variable name="y"/>
</head>
<results distinct="false" ordered="true">
 <result>
   <binding name="y"><literal xml:lang="en">John</literal></binding> //literals with language
 </result>
 <result>
   <binding name="y"><literal datatype="http://www.w3.org/2001/XMLSchema#integer">30</literal></binding> //typed literals
 </result>
...

要提取数据类型,您需要查询 Jena API。

于 2011-03-16T11:08:51.607 回答
0

假设没有语言标签:

SELECT  ?x ?y (DATATYPE(?y) AS ?dt)

请注意,如果 ?y 是纯文字,则 DATATYPE 返回xsd:string但 ?y 没有 ^^ 数据类型(直到 RDF 1.1)。

于 2012-08-07T20:31:18.873 回答