rdf 2025-01-25

I have a Turtle file that looks like this, generated using Donatello:

@prefix rdf: <> .
@prefix rdfs: <> .
@prefix ent: <tag:acme.com/initrode/pd/mm/id/e/> .
@prefix attr: <tag:acme.com/initrode/pd/mm/id/a/> .

ent:1efd782a-47b7-6790-8487-440cb3ab6e31 attr:paths "0101, 1010";
                                         attr:sop_ref_id 12345;
                                         attr:build "";
                                         attr:vendor "ACME";
                                         attr:cat 1;
                                         attr:project_code 8675309;
                                         attr:number "C2187";
                                         attr:pattern_type "p1x1";
                                         attr:elastic "no".
Trying to read this in with Raphael, I get errors about ; Prefix char starts with illegal character "<any of my objects/values above, does not matter>" Looking at the examples of generating Turtle files in the Donatello docs, I can't see what is problematic with what got generated here. The Raphael reader fails in this check: https://github.com/quoll/raphael/blob/main/src/quoll/raphael/core.cljc#L368 It's like it is expecting the values to be prefixed with an IRI and I am hoping someone spots something basic I am misunderstanding about how to generate the Turtle file (leading to it being unreadable).

A bit more on this. I am taking the Turtle generated by Donatello and trying to convert it to different formats using https://www.easyrdf.org/converter. As posted above, that web apps errors with *Error!* $resource should be either IRI, blank-node identifier or EasyRdf\Resource. got empty string So I added this prefix at the top of my file @base <> . and get the same error. But when I put into the Base URI field of the conversion input, then the conversion works as expected (the Turtle contents can be read and converted to JSON-LD or whatever). So I am guessing the issue is needing to apply some kind of IRI to the string literals I have as my values/objects. I am going to look into the typed-literal function in Donatello...

Can you file an issue on the Raphael GitHub project, please? I’ll try to look at this today

Hmmm, I'm having trouble replicating this

I've added the following to test/quoll/raphael/doc_test.cljc

(def document27
  "@prefix rdf: <> .
@prefix rdfs: <> .
@prefix ent: <tag:acme.com/initrode/pd/mm/id/e/> .
@prefix attr: <tag:acme.com/initrode/pd/mm/id/a/> .

ent:1efd782a-47b7-6790-8487-440cb3ab6e31 attr:paths \"0101, 1010\";
                                         attr:sop_ref_id 12345;
                                         attr:build \"\";
                                         attr:vendor \"ACME\";
                                         attr:cat 1;
                                         attr:project_code 8675309;
                                         attr:number \"C2187\";
                                         attr:pattern_type \"p1x1\";
                                         attr:elastic \"no\".")

(deftest document27-test
  (testing "Parsing of example27 document"
    (let [{:keys [base namespaces triples]} (parse document27)
          main-node (keyword "ent" "1efd782a-47b7-6790-8487-440cb3ab6e31")]
      (is (nil? base))
      (is (= namespaces {"rdf" ""
                         "rdfs" ""
                         "ent" "tag:"
                         "attr" "tag:
      (is (= (simplify triples)
             [[main-node :attr/paths "0101, 1010"]
              [main-node :attr/sop_ref_id 12345]
              [main-node :attr/build ""]
              [main-node :attr/vendor "ACME"]
              [main-node :attr/cat 1]
              [main-node :attr/project_code 8675309]
              [main-node :attr/number "C2187"]
              [main-node :attr/pattern_type "p1x1"]
              [main-node :attr/elastic "no"]])))))
The call to (simplify triples) converts IRIs to keywords.

This test works correctly.

Are you using the latest version?

I did discover that IRIs were not printing in a CIDER repl, because this tries to use clojure.pprint/write, which writes map-like objects by converting them to a seq, and IRI had not implemented the Seqable interface. I've been through all the interfaces that I didn't think IRIs needed to implement, and ensured that there is an method there for everything, so now it prints better in Cider. This is a new version of Raphael: 0.3.11