Using swrlb:divide seems to fail during some weird numeric conversions, see this standalone SQWRL query
swrlb:divide(?r, 5.0, 3.0) -> sqwrl:select(?r)
Exception:
Exception running SQWRL query S1: error running SQWRL queries: error running Drools rule engine:
[Error: invoker.invoke("S1", "swrlb:divide", 0, false, new VPATH(), new BAVNs("r", "", ""), new UBA("r"), new L("5.0", "xsd:decimal"), new L("3.0", "xsd:decimal")): runtime exception thrown by built-in swrlb:divide in rule S1: java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.]
[Near : {... invoker.invoke("S1", "swrlb:di ....}]
^
[Line: 1, Column: 1]: runtime exception thrown by built-in swrlb:divide in rule S1: java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.: error running Drools rule engine:
[Error: invoker.invoke("S1", "swrlb:divide", 0, false, new VPATH(), new BAVNs("r", "", ""), new UBA("r"), new L("5.0", "xsd:decimal"), new L("3.0", "xsd:decimal")): runtime exception thrown by built-in swrlb:divide in rule S1: java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.]
[Near : {... invoker.invoke("S1", "swrlb:di ....}]
^
[Line: 1, Column: 1]: runtime exception thrown by built-in swrlb:divide in rule S1: java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.: [Error: invoker.invoke("S1", "swrlb:divide", 0, false, new VPATH(), new BAVNs("r", "", ""), new UBA("r"), new L("5.0", "xsd:decimal"), new L("3.0", "xsd:decimal")): runtime exception thrown by built-in swrlb:divide in rule S1: java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.]
[Near : {... invoker.invoke("S1", "swrlb:di ....}]
^
[Line: 1, Column: 1]: runtime exception thrown by built-in swrlb:divide in rule S1: java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.: Non-terminating decimal expansion; no exact representable decimal result.
On the other hand, probably due to different implementation, the swrlm:eval extension works, try
swrlm:eval(?r, "5.0/3.0") -> sqwrl:select(?r)
Result:"1.6666666666666667"^^xsd:double
I guess, something is different with the literal conversion, the latter seems to use xsd:double literals, while the former works with xsd:decimal - but it's just a guess. By the way, XPath also uses either xsd:int or xsd:decimal.
Reported first on StackOverflow.
Setup
Protege 5.2.0 SWRLTab Protege Plugin 2.0.5
Problem
Using
swrlb:divide
seems to fail during some weird numeric conversions, see this standalone SQWRL queryException:
On the other hand, probably due to different implementation, the
swrlm:eval
extension works, tryResult:
"1.6666666666666667"^^xsd:double
I guess, something is different with the literal conversion, the latter seems to use
xsd:double
literals, while the former works withxsd:decimal
- but it's just a guess. By the way, XPath also uses eitherxsd:int
orxsd:decimal
.