The rule printing was originally intended for debugging and does not
guarantee full round tripping through the parser, though it is close.
The issue here is that "functors" are encoded as magic literals and the
serialization is writing out the literal raw instead of trying to
reverse engineer the encoding to produce the rule functor syntax.
Should be reasonably easy to extend the serializer to handle it. Feel
free to open a feature request, extra points for a patch to implement it :)
Dave
On 31/12/15 23:03, Chris Snyder wrote:
Hello,
I have a application that will initialize a reasoner and then let me modify
rules and apply them back to the reasoner. This has been working perfectly.
I have started to pull back some more advanced reasoner rules and when I try to
use them I am getting an error.
For example:
When I load up the RDFS reasoner at the FULL RDFS level and read back the rules
I get some rules that look like this:
[ -> (xsd:byte rb:xsdRange 'xsd(xsd:integer
'1'^^http://www.w3.org/2001/XMLSchema#int
'8'^^http://www.w3.org/2001/XMLSchema#int)'^^urn:x-hp-jena:Functor) ]
If I try to parse these rules using my rulesFromString method which calls the
Jena Rule methods for parsing:
/**
* Answer the list of rules parsed from the given string.
*
* @throws RulesetNotFoundException
*/
public static List<Rule> rulesFromString(String ruleInput) {
BufferedReader br = null;
try {
StringReader sr = new StringReader(ruleInput);
br = new BufferedReader(sr);
return Rule.parseRules(Rule.rulesParserFromReader(br));
} finally {
if (br != null)
try {
br.close();
} catch (IOException e2) {
}
}
I get a parser error on the ^^http part.
Exception in thread "AWT-EventQueue-0"
org.apache.jena.reasoner.rulesys.Rule$ParserException: Unrecognized qname prefix
(1'^^http) in rule
At 'xsd:dateTime ) ] [ -> ( xsd:duration rb:xsdBase xsd:duration ) ] [ -> (
xsd:byte rb:xsdRange ' xsd(xsd:integer ' 1'^^http://www.w3.org/2001/XMLSchema#int '
at org.apache.jena.reasoner.rulesys.Rule$Parser.parseNode(Rule.java:857)
at
org.apache.jena.reasoner.rulesys.Rule$Parser.parseNodeList(Rule.java:939)
at
org.apache.jena.reasoner.rulesys.Rule$Parser.parseClause(Rule.java:954)
at
org.apache.jena.reasoner.rulesys.Rule$Parser.doParseRule(Rule.java:1021)
at org.apache.jena.reasoner.rulesys.Rule$Parser.parseRule(Rule.java:986)
at org.apache.jena.reasoner.rulesys.Rule.parseRules(Rule.java:636)
at
net.mind_tap.kbswt.GUI.JenaRulePanel.rulesFromString(JenaRulePanel.java:313)
at
net.mind_tap.kbswt.GUI.JenaRulePanel$5.actionPerformed(JenaRulePanel.java:270)
….
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
It looks like this should be working as the initial construction of the
reasoner appears to go through the same process to setup the initial rules. Any
ideas as to what I am missing here?
Thanks,
Chris
P.S. I hope everyone has a Happy New Year.