1:- module(
2 rdf_export,
3 [
4 rdf_write_quad/2, 5 rdf_write_quad/3, 6 rdf_write_triple/2, 7 rdf_write_tuple/2 8 ]
9).
17:- use_module(library(lists)). 18:- use_module(library(semweb/turtle), []). 19
20:- use_module(library(hash_ext)). 21:- use_module(library(rdf_prefix)). 22:- use_module(library(rdf_term)). 23
24:- rdf_meta
25 rdf_write_iri(+, r), rdf_write_literal(+, o), rdf_write_name(+, o), rdf_write_quad(+, t), rdf_write_quad(+, t, r), rdf_write_quad(+, r, r, o, r), rdf_write_triple(+, t), rdf_write_tuple(+, t).
40rdf_write_graph(Out, G) :-
41 rdf_write_iri(Out, G).
47rdf_write_iri(Out, Iri) :-
48 turtle:turtle_write_uri(Out, Iri).
54rdf_write_literal(Out, Input) :-
55 rdf_literal_dwim(Input, Literal),
56 rdf_write_literal_(Out, Literal).
57
58rdf_write_literal_(Out, literal(lang(LTag,Lex))) :- !,
59 turtle:turtle_write_quoted_string(Out, Lex),
60 format(Out, "@~a", [LTag]).
61rdf_write_literal_(Out, literal(type(D,Lex))) :-
62 turtle:turtle_write_quoted_string(Out, Lex),
63 format(Out, "^^", []),
64 rdf_write_iri(Out, D).
71rdf_write_name(Out, Iri) :-
72 rdf_is_iri(Iri), !,
73 rdf_write_iri(Out, Iri).
75rdf_write_name(Out, Literal) :-
76 rdf_is_literal(Literal),
77 rdf_write_literal(Out, Literal).
87rdf_write_quad(Out, tp(S,P,O,G)) :-
88 rdf_write_triple_open_(Out, tp(S,P,O)),
89 put_char(Out, ' '),
90 rdf_write_graph(Out, G),
91 format(Out, ".\n", []).
92
93
94rdf_write_quad(Out, tp(S,P,O), G) :- !,
95 rdf_write_quad(Out, tp(S,P,O,G)).
96rdf_write_quad(Out, tp(S,P,O,_), G) :-
97 rdf_write_quad(Out, tp(S,P,O,G)).
103rdf_write_term(Out, Iri) :-
104 rdf_is_iri(Iri), !,
105 rdf_write_iri(Out, Iri).
106rdf_write_term(Out, Literal) :-
107 rdf_write_literal(Out, Literal).
116rdf_write_triple(Out, tp(S,P,O)) :- !,
117 rdf_write_triple_open_(Out, tp(S,P,O)),
118 format(Out, ".\n", []).
119rdf_write_triple(Out, tp(S,P,O,_)) :-
120 rdf_write_triple(Out, tp(S,P,O)).
121
122rdf_write_triple_open_(Out, tp(S,P,O)) :-
123 rdf_write_term(Out, S),
124 put_char(Out, ' '),
125 rdf_write_iri(Out, P),
126 put_char(Out, ' '),
127 rdf_write_term(Out, O).
136rdf_write_tuple(Out, tp(S,P,O)) :- !,
137 rdf_write_triple(Out, tp(S,P,O)).
138rdf_write_tuple(Out, tp(S,P,O,G)) :-
139 rdf_write_quad(Out, tp(S,P,O,G))
RDF export
RDF export predicates that are backend-independent.
*/