Closed JanWielemaker closed 9 years ago
Great proposal! Improving literal assertion and named graph retrieval will make Semweb more versatile as well as more compliant with RDF 1.1. Some comments:
In Semweb the following currently asserts exactly one triple, disregarding the datatype entirely:
?- rdf_assert(rdf:s, rdf:p, literal(1)).
?- rdf_assert(rdf:s, rdf:p, literal(type(xsd:integer,1))).
?- rdf_assert(rdf:s, rdf:p, literal(type(xsd:nonNegativeInteger,1))).
Currently Semweb does not correctly allow some literals to be asserted using lexical expressions and some literals to be asserted using values.
The following should assert exactly one triple, since lexical expression '1'
maps to value 1
according to the lexical-to-value mapping of datatype XSD integer.
?- rdf_assert(rdf:s, rdf:p, literal(type(xsd:integer,1))).
?- rdf_assert(rdf:s, rdf:p, literal(type(xsd:integer,'1'))).
Result:
?- rdf(S, P, O).
S = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#s',
P = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#p',
O = literal(type('http://www.w3.org/2001/XMLSchema#integer', 1)) ;
S = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#s',
P = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#p',
O = literal(type('http://www.w3.org/2001/XMLSchema#integer', '1')).
The terms "simple literal" and "plain literal" have both been dropped in RDF 1.1. The former are now XSD strings. Some of the latter are now XSD strings and some of the latter are now RDF language-tagged strings.
I tried to incorporate these point into the wiki: https://github.com/SWI-Prolog/packages-semweb/wiki/Proposal-for-Semweb-library-redesign
@JanWielemaker Can you check whether all your points were sufficiently included and then close this issue?
Status
Literal handling in rdf_db is outdated and not practical. Currently, literals have the form
literal(Atom)
literal(lang(LangAtom, TextAtom))
literal(type(TypeIRI, Value)
, where Value is one ofrdf_assert/3,4
All literals are sorted, but the sorting has little relation to the SPARQL defined ordering. This implies we cannot optimize SPARQL queries that use comparison operators.
Issues
rdf_assert/3,4
to assert a plain literal as xsd:string. That might be better?Ideal
By type:
The 4th argument must be the graph (an IRI, atom). We need a new rdf/5 (probably with a different name to query <S,P,O,G,Line>. The Line has different meanings:
Line
was the line in the file from which the triple was loaded.library(rdf_persistency)
uses `Line' as time stamp to correlate transactions on different graphs.What about saying that a triple is identified by <S,P,O,G> and have a predicate
rdf_triple_property(S,P,O,G,Property)
to query additional properties (last access, line, etc.)?In retrospect, I think the value of an XMLLiteral should be the (canonical) XML serialization rather than the DOM tree. Other types:
"03-19"^^xsd:gMonthDay
and have a library dealing with them? After all, AFAIK, SPARQL defines different data/time types not to be comparable and they all compare as expected when compared alphabetically. Notably XML Schema defines min/max|inclusive/exclusive on them.Compatibility