我对这个主题还比较陌生,希望有人能帮我。
我目前在使用sqwrl比较本体数据时遇到了一个问题。内置的 swrlb:stringEqualIgnoreCase
-sqwrl中的函数不允许我比较 rdf:PlainLiteral
使用普通字符串。引发以下错误消息:
org.swrlapi.exceptions.SWRLBuiltInException: exception thrown by built-in swrlb:stringEqualIgnoreCase in rule q2: cannot convert value of type rdf:PlainLiteral to xsd:string
sqwrl查询:
ctest:Operation(?o) ^ ctest:name(?o, ?n) ^ swrlb:stringEqualIgnoreCase(?n, \"testop\") -> sqwrl:select(?o, ?n)
数据本身被标记为 ^^http://www.w3.org/2001/XMLSchema#string
在graphdb中,但我只是简单地接受它。
有没有什么简单的方法来转换 rdf:PlainLiteral
至 xsd:string
使用owlapi或其他工具?
编辑:堆栈跟踪
[Error: invoker.invoke("q2", "swrlb:stringEqualIgnoreCase", 0, false, new VPATH($o), new BAVNs("n", ""), $n, new L("testop", "xsd:string")): built-in exception thrown by built-in swrlb:stringEqualIgnoreCase in rule q2: exception thrown by built-in swrlb:stringEqualIgnoreCase in rule q2: cannot convert value of type rdf:PlainLiteral to xsd:string]
[Near : {... invoker.invoke("q2", "swrlb:st ....}]
^
[Line: 1, Column: 1]: built-in exception thrown by built-in swrlb:stringEqualIgnoreCase in rule q2: exception thrown by built-in swrlb:stringEqualIgnoreCase in rule q2: cannot convert value of type rdf:PlainLiteral to xsd:string
at org.swrlapi.factory.DefaultSWRLRuleAndQueryEngine.runSQWRLQuery(DefaultSWRLRuleAndQueryEngine.java:121)
at org.swrlapi.factory.DefaultSWRLRuleAndQueryEngine.runSQWRLQuery(DefaultSWRLRuleAndQueryEngine.java:156)
at at.fhv.cidop.manager.bidding.SQWRL.SqwrlExperimenter.main(SqwrlExperimenter.java:101)
Caused by: org.swrlapi.exceptions.TargetSWRLRuleEngineException: error running Drools rule engine:
[Error: invoker.invoke("q2", "swrlb:stringEqualIgnoreCase", 0, false, new VPATH($o), new BAVNs("n", ""), $n, new L("testop", "xsd:string")): built-in exception thrown by built-in swrlb:stringEqualIgnoreCase in rule q2: exception thrown by built-in swrlb:stringEqualIgnoreCase in rule q2: cannot convert value of type rdf:PlainLiteral to xsd:string]
[Near : {... invoker.invoke("q2", "swrlb:st ....}]
^
[Line: 1, Column: 1]: built-in exception thrown by built-in swrlb:stringEqualIgnoreCase in rule q2: exception thrown by built-in swrlb:stringEqualIgnoreCase in rule q2: cannot convert value of type rdf:PlainLiteral to xsd:string
at org.swrlapi.drools.core.DroolsSWRLRuleEngine.runRuleEngine(DroolsSWRLRuleEngine.java:219)
at org.swrlapi.factory.DefaultSWRLRuleAndQueryEngine.run(DefaultSWRLRuleAndQueryEngine.java:90)
at org.swrlapi.factory.DefaultSWRLRuleAndQueryEngine.runSQWRLQuery(DefaultSWRLRuleAndQueryEngine.java:118)
... 2 more
Caused by: [Error: invoker.invoke("q2", "swrlb:stringEqualIgnoreCase", 0, false, new VPATH($o), new BAVNs("n", ""), $n, new L("testop", "xsd:string")): built-in exception thrown by built-in swrlb:stringEqualIgnoreCase in rule q2: exception thrown by built-in swrlb:stringEqualIgnoreCase in rule q2: cannot convert value of type rdf:PlainLiteral to xsd:string]
[Near : {... invoker.invoke("q2", "swrlb:st ....}]
^
[Line: 1, Column: 1]
at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:435)
at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:163)
at org.mvel2.ast.ASTNode.optimize(ASTNode.java:159)
at org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:115)
at org.mvel2.MVELRuntime.execute(MVELRuntime.java:85)
at org.mvel2.compiler.CompiledExpression.getDirectValue(CompiledExpression.java:123)
at org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:119)
at org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:113)
at org.mvel2.MVEL.executeExpression(MVEL.java:941)
at org.drools.core.util.MVELSafeHelper$RawMVELEvaluator.executeExpression(MVELSafeHelper.java:501)
at org.drools.core.base.dataproviders.MVELDataProvider.evaluate(MVELDataProvider.java:138)
at org.drools.core.base.dataproviders.MVELDataProvider.getResults(MVELDataProvider.java:133)
at org.drools.core.phreak.PhreakFromNode.doLeftInserts(PhreakFromNode.java:106)
at org.drools.core.phreak.PhreakFromNode.doNode(PhreakFromNode.java:68)
at org.drools.core.phreak.RuleNetworkEvaluator.evalNode(RuleNetworkEvaluator.java:387)
at org.drools.core.phreak.RuleNetworkEvaluator.innerEval(RuleNetworkEvaluator.java:333)
at org.drools.core.phreak.RuleNetworkEvaluator.outerEval(RuleNetworkEvaluator.java:169)
at org.drools.core.phreak.RuleNetworkEvaluator.evaluateNetwork(RuleNetworkEvaluator.java:127)
at org.drools.core.phreak.RuleExecutor.reEvaluateNetwork(RuleExecutor.java:212)
at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:87)
at org.drools.core.concurrent.AbstractRuleEvaluator.internalEvaluateAndFire(AbstractRuleEvaluator.java:34)
at org.drools.core.concurrent.SequentialRuleEvaluator.evaluateAndFire(SequentialRuleEvaluator.java:43)
at org.drools.core.common.DefaultAgenda.fireLoop(DefaultAgenda.java:1072)
at org.drools.core.common.DefaultAgenda.internalFireAllRules(DefaultAgenda.java:1019)
at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1011)
at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1321)
at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1312)
at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1304)
at org.swrlapi.drools.core.DroolsSWRLRuleEngine.runRuleEngine(DroolsSWRLRuleEngine.java:211)
... 4 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:1120)
at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:1003)
at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:396)
... 32 more
Caused by: org.swrlapi.exceptions.SWRLAPIException: built-in exception thrown by built-in swrlb:stringEqualIgnoreCase in rule q2: exception thrown by built-in swrlb:stringEqualIgnoreCase in rule q2: cannot convert value of type rdf:PlainLiteral to xsd:string
at org.swrlapi.drools.core.DroolsSWRLBuiltInInvoker.invoke(DroolsSWRLBuiltInInvoker.java:417)
at org.swrlapi.drools.core.DroolsSWRLBuiltInInvoker.invoke(DroolsSWRLBuiltInInvoker.java:90)
... 39 more
Caused by: org.swrlapi.exceptions.SWRLBuiltInException: exception thrown by built-in swrlb:stringEqualIgnoreCase in rule q2: cannot convert value of type rdf:PlainLiteral to xsd:string
at org.swrlapi.builtins.AbstractSWRLBuiltInLibrary.invokeBuiltInMethod(AbstractSWRLBuiltInLibrary.java:226)
at org.swrlapi.builtins.SWRLBuiltInLibraryManager.invokeSWRLBuiltIn(SWRLBuiltInLibraryManager.java:184)
at org.swrlapi.factory.DefaultSWRLBridge.invokeSWRLBuiltIn(DefaultSWRLBridge.java:150)
at org.swrlapi.drools.core.DroolsSWRLBuiltInInvoker.invoke(DroolsSWRLBuiltInInvoker.java:399)
... 40 more
Caused by: org.swrlapi.exceptions.LiteralException: cannot convert value of type rdf:PlainLiteral to xsd:string
at org.swrlapi.factory.DefaultLiteral.getString(DefaultLiteral.java:186)
at org.swrlapi.builtins.AbstractSWRLBuiltInLibrary.getArgumentAsAString(AbstractSWRLBuiltInLibrary.java:1232)
at org.swrlapi.builtins.swrlb.SWRLBuiltInLibraryImpl.stringEqualIgnoreCase(SWRLBuiltInLibraryImpl.java:497)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.swrlapi.builtins.AbstractSWRLBuiltInLibrary.invokeBuiltInMethod(AbstractSWRLBuiltInLibrary.java:219)
... 43 more
暂无答案!
目前还没有任何答案,快来回答吧!