Rdf_meta and dynamic/2 don't play nice

Hello,

I am using rdf_meta to be able to use abbreviated notation for RDF resources. For example, the directive :

rdf_meta
    my_pred(r).

allows me to call my_pred(dpe:p1). rather than the fully quantified URI.

However, when my_pred is defined over multiple files (using dynamic/2) this no longer seems to work as illustrated by the following example that is composed of two modules (base and ext), and a scenario from the SWI. command line

base.pl:

:- module(base,[t_ok/1,t_nok/1]).
:- dynamic([t_ok/1,t_nok/1],[multifile(true)]).

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

:- rdf_meta
	t_ok(r),
	t_nok(r).     % note t_nok/1 is defined in ext.pl (but it is part of the "base" module)

t_ok(dc:a).         % dc:a is an abbreviated. URI 

ext.pl:

:- module(ext,[]).
:- reexport(base).

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

:- dynamic([base:t_nok/1],[multifile(true)]).

base:t_nok(dc:b).         % dc:b is an abbreviated. URI 

the scenario :

% swipl        
Welcome to SWI-Prolog (threaded, 64 bits, version 8.1.25-4-ge2c781d07)
?- [ext].   % this also loads base
true.
?- use_module(library(semweb/rdf11)).
true.
?- rdf_assert(dc:a,p,o),rdf_assert(dc:b,p,o).    % populate the repository with two triples
true.
?- t_ok(S),rdf_subject(S).                       % all is fine for t_ok/1 that is defined in base.pl
S = 'http://purl.org/dc/elements/1.1/a'.         
?- t_nok(S),rdf_subject(S).                      % however t_nok/1 that is defined in ext.pl, but part of 
                                                 % base.pl, thinks dc:b is a compound term iso an abbreviated URI
ERROR: Type error: `atom' expected, found `dc:b' (a compound)
ERROR: In:
ERROR:   [12] rdf_db:rdf_resource(dc:b)
ERROR:   [11] rdf_db:rdf_subject(dc:b) at /usr/local/lib/swipl/library/semweb/rdf_db.pl:522
ERROR:    [9] <user>
...

Is there a way to convince rdf_meta to work with predicates defined over multiple modules, or am I pushing my luck here? Many thanks for any hints you may have

Joost

2 Likes

Thanks. Fixed.

2 Likes

Wonderfull, thanks Jan!