我正在使用 java WS 来查询存储库。我无法更改此存储库中的数据。当我查询任何内容时,如果任何变量具有“数据类型”属性,我会得到重复的结果。
有没有办法只使用查询来删除重复项?
谢谢你的帮助。问题示例如下,
我的固定命名空间
public static final String PREFIX = "prefix kb: <http://protege.stanford.edu/kb#>\n" +
"prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n" +
"prefix owl: <http://www.w3.org/2002/07/owl#>\n" +
"prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" +
"prefix xsd: <http://www.w3.org/2001/XMLSchema#>\n";
我的查询字符串
String query = "SELECT DISTINCT ?name WHERE {" +
"?unit a kb:Unit ; " +
"kb:hasName ?name ;" +
"} ORDER BY ?name ";
当我使用此查询时,我会得到带有“数据类型”的重复值,例如
<?xml version="1.0"?>
<sparql xmlns="http://www.w3.org/2005/sparql-results#">
<head>
<variable name="name"/>
</head>
<results>
<result>
<binding name="name">
<literal>Hours</literal>
</binding>
</result>
<result>
<binding name="name">
<literal>Meters per Hour</literal>
</binding>
</result>
<result>
<binding name="name">
<literal datatype="http://www.w3.org/2001/XMLSchema#string">Meters per Hour</literal>
</binding>
</result>
<result>
<binding name="name">
<literal>Meters per Minute</literal>
</binding>
</result>
<result>
<binding name="name">
<literal>PercentageCompleted</literal>
</binding>
</result>
<result>
<binding name="name">
<literal>Pieces per Hour</literal>
</binding>
</result>
<result>
<binding name="name">
<literal datatype="http://www.w3.org/2001/XMLSchema#string">Pieces per Hour</literal>
</binding>
</result>
<result>
<binding name="name">
<literal>Pieces per Minute</literal>
</binding>
</result>
<result>
<binding name="name">
<literal datatype="http://www.w3.org/2001/XMLSchema#string">Pieces per Minute</literal>
</binding>
</result>
<result>
<binding name="name">
<literal>Product parts</literal>
</binding>
</result>
<result>
<binding name="name">
<literal>Products per Day</literal>
</binding>
</result>
<result>
<binding name="name">
<literal datatype="http://www.w3.org/2001/XMLSchema#string">Products per Day</literal>
</binding>
</result>
<result>
<binding name="name">
<literal>SI Cubic Meter</literal>
</binding>
</result>
<result>
<binding name="name">
<literal>€ per Hour</literal>
</binding>
</result>
<result>
<binding name="name">
<literal>€ per Minute</literal>
</binding>
</result>
<result>
<binding name="name">
<literal>€ per Product</literal>
</binding>
</result>
</results>
</sparql>