1
votes

Trying to save rdf triples to a file using the semweb package in swi-prolog, but keep getting an error and the triples are not saved correctly.

The following small code shows the problem with swi-prolog version 7.6.4 on Ubuntu Bionic.

PS: Please ignore the 'rdf:xyz' predicate as I tend to use it without needing to add new prefixes

:- use_module(library(semweb/rdf_db)).

assert_test :-
    rdf_bnode(Node),
    rdf_assert(Node, rdf:xyz, literal(type(xsd:string, "foobar"))),
    rdf_save('foo.xml').

I get the following error (showing top lines only):

ERROR: Unknown error term: save_attribute_value("foobar")
ERROR: In:
ERROR:   [25] throw(error(save_attribute_value("foobar"),_980))
.
.
.

The file is created, but does not have the full triple.

An interesting side note, it works if I use rdf_save_turtle instead of rdf_save. Any help is appreciated.

1
Based on my first glance at the docs, I think you should try passing an atom instead of a Prolog string, i.e. rdf_assert(Node, rdf:xyz, literal(type(xsd:string, foobar))) or perhaps using just literal(foobar) or literal(lang(en, foobar)). - Daniel Lyons
ugh! You are right (I should have read the documentation more carefully). Interesting though rdf_save_turtle works with the string. Not sure how I can accept a comment as an answer...If you could convert that into an official answer I can try and accept it :) - stan_plogic

1 Answers

1
votes

Based on my first glance at the docs, I think you should try passing an atom instead of a Prolog string, i.e.

rdf_assert(Node, rdf:xyz, literal(type(xsd:string, foobar))) 

or perhaps using just literal(foobar) or literal(lang(en, foobar)).