On 08/10/2020 07:41, Marcelo Machado wrote:
I am trying to create my own property rules in fuseki. To do so I am using
the Generic Rule Reasoning that allows me to use my own rules. When I use
this strategy with my rules in a file everything works fine:

:model_inf a ja:InfModel ;
     ja:baseModel :tdbGraph ;
     ja:reasoner [
         ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
         ja:rulesFrom <file://...> ;
     ] .

However, I would not want to use a file but add the rules directly as a
string. I tried just to copy the content of the rule files that worked in
the example above, but the repository was not created, apparently due to
special characters (e.g. #, \n...):

:model_inf a ja:InfModel ;
     ja:baseModel :tdbGraph ;
     ja:reasoner [
         ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
         ja:rule "[${string_rules_variable}]"`;

At a minimum that will need Turtle escapes for newlines. A NodeFormatter formst outout - the Turtle rules are available directly via EscapeStr.stringEsc(string).

The full grammar details are here: https://www.w3.org/TR/turtle/#terminals

If you need to be it your self, it'll need newline and " handling, two character \n and \"

    Andy

     ] .
where ${string_rules_variable} (javascript string interpolation) contains
the rules read from the file.

So, what am I doing wrong? I believe this is about escaping special
characters, if so, what would be the way to resolve it?

At.te,

Marcelo de Oliveira Costa Machado

Reply via email to