Java OWLS使用Jena解析文档

Java OWLS使用Jena解析文档,java,sparql,jena,Java,Sparql,Jena,我在用Jena解析OWLS文档(RDF)时遇到问题 该文档是猫头鹰的基础,其中有一段我感兴趣的代码: <grounding:WsdlAtomicProcessGrounding rdf:ID="wsdl_Grounding"> <grounding:owlsProcess rdf:resource="process"/> <grounding:wsdlOperation> <

我在用Jena解析OWLS文档(RDF)时遇到问题

该文档是猫头鹰的基础,其中有一段我感兴趣的代码:

<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)
我构建的所有查询都有效,但这种查询除外,它具有链接属性, 在我的例子中,链接属性是;wsdlOperation、WsdlOperationRef和端口类型


提前感谢;)

您确定链接属性有效吗?如果你试着说出中间的概念会怎么样:

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:WsdlOperationRef ?or .
  ?or grounding:portType ?y .
}

您需要确保使用的是SPARQL 1.1语法。默认值是SPARQL 1.0,它不支持属性路径。使用接受
com.hp.hpl.jena.query.Syntax
参数的API调用,并传递
syntaxSPARQL\u 11
常量。

感谢除我之外的所有人找到了解决方案

我尝试了RobV的解决方案,但它不起作用,所以我开始用较少的条件重复查询,我发现Jena在下面的查询中返回0:b0

前缀接地:http://www.daml.org/services/owl-s/1.2/Grounding.owl"
选择?op
哪里
{
?x接地:hasAtomicProcessGrounding?apg。
?apg接地:wsdlOperation?op
}

我看到Jena在查询的下一部分中使用了这个值,而没有找到下一个属性

但问题是,当我请求“grounding:wsdlOperation”时,Jena返回一个“grounding:WsdlOperationRef”对象的引用,作为失败查询下一部分的主题,因此我不能请求“grounding:WsdlOperationRef”,因为这个元素是我以前获得的主题引用

因此,解决方案是下一个(不带“WsdlOperationRef”属性):

前缀接地:http://www.daml.org/services/owl-s/1.2/Grounding.owl"
选择?x y?
哪里
{
?x接地:hasAtomicProcessGrounding?apg。
?apg接地:wsdlOperation?op。
?op接地:端口类型?y。

}

谢谢,但我可以通过链式查询获得文档的其他部分,它使用的是1.1版本。我又试了一次使用常量syntaxSPARQL_11,但没有任何改变。如果没有看到完整的测试用例,很难说更多。你有没有可能发布一个更完整的例子来说明你在做什么?我想Andy在最近的一个ARQ版本中将默认语法改为SPARQL 1.1。我已经测试了链式属性及其工作原理,我尝试了中间概念,但是当我有一个属性,在查询中只有另一个属性时,似乎不会返回任何值。
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:WsdlOperationRef ?or .
  ?or grounding:portType ?y .
}