OWLS 使用 Jena 进行文档解析
我在使用 Jena 解析 OWLS 文档 (RDF) 时遇到问题。
该文档是 OWLS Grounding,有一段我感兴趣的代码:
<grounding:WsdlAtomicProcessGrounding rdf:ID="wsdl_Grounding">
<grounding:owlsProcess rdf:resource="process"/>
<grounding:wsdlOperation>
<grounding:WsdlOperationRef>
<grounding:portType rdf:datatype="&xsd;#anyURI">&WSDL;#operationPort</grounding:portType>
<grounding:operation rdf:datatype="&xsd;#anyURI">&WSDL;#operationPort</grounding:operation>
</grounding:WsdlOperationRef>
</grounding:wsdlOperation>
...(the OWLS Grounding continues)
我想获取“portType”值,但是如果我尝试使用下一个 SPARQL 代码,我没有得到任何结果。
PREFIX grounding: "http://www.daml.org/services/owl-s/1.2/Grounding.owl"
SELECT ?x y?
WHERE {
?x grounding:hasAtomicProcessGrounding/grounding:wsdlOperation/grounding:WsdlOperationRef/grounding:portType ?y
};
我构建的所有查询都有效,除了这种具有链接属性的查询, 就我而言,链接属性是; wsdlOperation、WsdlOperationRef 和 portType。
提前致谢 ;)
I've got a problem while parsing a OWLS Document (RDF) with Jena.
The document is the OWLS Grounding, there are a piece of code of my interest:
<grounding:WsdlAtomicProcessGrounding rdf:ID="wsdl_Grounding">
<grounding:owlsProcess rdf:resource="process"/>
<grounding:wsdlOperation>
<grounding:WsdlOperationRef>
<grounding:portType rdf:datatype="&xsd;#anyURI">&WSDL;#operationPort</grounding:portType>
<grounding:operation rdf:datatype="&xsd;#anyURI">&WSDL;#operationPort</grounding:operation>
</grounding:WsdlOperationRef>
</grounding:wsdlOperation>
...(the OWLS Grounding continues)
I want to get the "portType" value, but if I try with the next SPARQL code I've got no results.
PREFIX grounding: "http://www.daml.org/services/owl-s/1.2/Grounding.owl"
SELECT ?x y?
WHERE {
?x grounding:hasAtomicProcessGrounding/grounding:wsdlOperation/grounding:WsdlOperationRef/grounding:portType ?y
};
All the queries I build works except this kind of query, which have chained properties,
in my case the chained properties are; wsdlOperation, WsdlOperationRef, and portType.
Thanks in advance ;)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要确保使用 SPARQL 1.1 语法。默认为 SPARQL 1.0,不支持属性路径。使用接受
com.hp.hpl.jena.query.Syntax
参数并传递syntaxSPARQL_11
常量的 API 调用。You need to ensure that you are using SPARQL 1.1 syntax. The default is SPARQL 1.0, which does not support property paths. Use the API calls which accept a
com.hp.hpl.jena.query.Syntax
parameter, and pass thesyntaxSPARQL_11
constant.您确定连锁属性有效吗?如果您尝试阐明中间概念会怎样:
Are you sure chained properties work? What if you try spell out the intermediate concepts:
感谢大家,但我已经找到了解决方案。
我尝试过 RobV 的解决方案,但它不起作用,所以我开始用更少的条件重复查询,我发现使用以下查询 Jena 返回 _:b0。
前缀接地:“http://www.daml.org/services/owl-s/1.2/Grounding.owl”
选择?
在哪里
{
?x 接地:hasAtomicProcessGrounding ?apg 。
?apg 接地:wsdlOperation ?op
我看到 Jena 在查询的下一部分中使用该值
?op grounding:WsdlOperationRef ?or .
(使用 ?op == _ :b0)并且找不到下一个属性。
但问题是,当我请求“grounding:wsdlOperation”时,Jena 返回“grounding:WsdlOperationRef”对象的引用,将“_:b0”作为失败查询下一部分的主题,所以我不能询问对于“grounding:WsdlOperationRef”,因为该元素是我之前获得的主题引用。
因此,解决方案是下一个(没有“WsdlOperationRef”属性):
PREFIX 接地:“http://www.daml.org/services/owl-s/1.2/Grounding.owl”
选择?xy?
在哪里
{
?x 接地:hasAtomicProcessGrounding ?apg 。
?apg 接地:wsdlOperation ?op。
?op 接地:portType ?y 。
}
Thanks to all but I've found the solution.
I've try the solution of RobV, but It doesn't work, so I started to repeat the query with less conditions, and I've found that with the following query Jena returns _:b0.
PREFIX grounding: "http://www.daml.org/services/owl-s/1.2/Grounding.owl"
SELECT ?op
WHERE
{
?x grounding:hasAtomicProcessGrounding ?apg .
?apg grounding:wsdlOperation ?op
}
And I see that Jena use that value for the next part of the query
?op grounding:WsdlOperationRef ?or .
(with ?op == _:b0) and don't find the next property.But the problem was that when I ask for "grounding:wsdlOperation" Jena returns a reference for the "grounding:WsdlOperationRef" object acting "_:b0" as a subject for the next part of the failed query, so I can't ask for "grounding:WsdlOperationRef" because this element was the subject reference I've obtained before.
So the solution is the next one (without the "WsdlOperationRef" property):
PREFIX grounding: "http://www.daml.org/services/owl-s/1.2/Grounding.owl"
SELECT ?x y?
WHERE
{
?x grounding:hasAtomicProcessGrounding ?apg .
?apg grounding:wsdlOperation ?op.
?op grounding:portType ?y .
}